Skip to content

Instantly share code, notes, and snippets.

@dcomartin

dcomartin/Repository.cs Secret

Created Feb 10, 2021
Embed
What would you like to do?
public class ShoppingCartDomainRepository
{
private readonly SalesDbContext _dbContext;
public ShoppingCartDomainRepository(SalesDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<ShoppingCartDomain> GetShoppingCart(Guid shoppingCartId)
{
var data = await _dbContext.ShoppingCarts
.Include(x => x.Items)
.SingleAsync(x => x.ShoppingCartId == shoppingCartId);
return new ShoppingCartDomain(data);
}
public async Task Save()
{
await _dbContext.SaveChangesAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment