Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created February 10, 2021 22:41
Show Gist options
  • Save dcomartin/25bdff853318b14ccfbf5e4005f7c9e6 to your computer and use it in GitHub Desktop.
Save dcomartin/25bdff853318b14ccfbf5e4005f7c9e6 to your computer and use it in GitHub Desktop.
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