public async Task AddToCartAsync(Album album, string shoppingCartId) { var cartItem = await _context.Carts.SingleOrDefaultAsync(x => x.CartId == shoppingCartId && x.AlbumId == album.Id); if (cartItem == null) { cartItem = new Cart() { AlbumId = album.Id, CartId = shoppingCartId, Count = 1, DateCreated = DateTime.UtcNow }; _context.Carts.Add(cartItem); } else { cartItem.Count++; } await _context.SaveChangesAsync(); }
public async Task UpdateAlbumAsync(Album album) { _context.Entry(album).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task RemoveAlbumAsync(Album album) { _context.Albums.Remove(album); await _context.SaveChangesAsync(); }
public async Task CreateAlbum(Album album) { _context.Albums.Add(album); await _context.SaveChangesAsync(); }