File size: 775 Bytes
c2908d2
a19fd25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2908d2
8ded86b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Microsoft.EntityFrameworkCore;
using OilShopManagement.Data;
using OilShopManagement.Models;

namespace OilShopManagement.Repositories;

public class StockRepository : Repository<StockTransaction>, IStockRepository
{
    public StockRepository(ApplicationDbContext context) : base(context) { }

    public async Task<IEnumerable<StockTransaction>> GetByProductAsync(int productId) =>
        await _dbSet.Include(st => st.Product)
            .Where(st => st.ProductId == productId)
            .OrderByDescending(st => st.CreatedAt).ToListAsync();

    public async Task<IEnumerable<StockTransaction>> GetRecentAsync(int count = 20) =>
        await _dbSet.Include(st => st.Product)
            .OrderByDescending(st => st.CreatedAt).Take(count).ToListAsync();
}