working customer post, get and delete

This commit is contained in:
2023-06-07 14:47:00 +02:00
parent ad998e0499
commit c805ce20a8
26 changed files with 448 additions and 142 deletions

View File

@@ -0,0 +1,36 @@
using AB.Domain.Entities;
using AB.Domain.Repositories;
using Microsoft.EntityFrameworkCore;
namespace AB.Persistence.Repos;
public class CustomerRepository : ICustomerRepository
{
private readonly RepoDbContext _dbContext;
public CustomerRepository(RepoDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<IEnumerable<Customer>> GetAllAsync(CancellationToken cancellationToken)
{
return await _dbContext.Customers.ToListAsync(cancellationToken);
}
public async Task<Customer> GetByIdAsync(Guid customerId, CancellationToken cancellationToken)
{
return await _dbContext.Customers.FirstOrDefaultAsync(x => x.CustomerId == customerId, cancellationToken);
}
public void Insert(Customer customer)
{
_dbContext.Customers.Add(customer);
}
public void Remove(Customer customer)
{
_dbContext.Customers.Remove(customer);
}
}