add supplier repo and suppliercreationdto
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using AB.Domain.Entities;
|
||||
using AB.Domain.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,9 +9,33 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Persistence.Repos;
|
||||
|
||||
public class SupplierRepository
|
||||
public class SupplierRepository : ISupplierRepository
|
||||
{
|
||||
private readonly RepoDbContext _dbContext;
|
||||
|
||||
public SupplierRepository(RepoDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Supplier>> GetAllAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbContext.Suppliers.ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Supplier> GetByIdAsync(Guid supplierId, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbContext.Suppliers.FirstOrDefaultAsync(x => x.SupplierId == supplierId, cancellationToken);
|
||||
}
|
||||
|
||||
public void Insert(Supplier supplier)
|
||||
{
|
||||
_dbContext.Add(supplier);
|
||||
}
|
||||
|
||||
public void Remove(Supplier supplier)
|
||||
{
|
||||
|
||||
_dbContext.Suppliers.Remove(supplier);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user