public void AddToCart(Album album) { // Get the matching cart and album instances var cartItem = _cartAppService.Find( c => c.CartId == ShoppingCartId && c.AlbumId == album.AlbumId).SingleOrDefault(); if (cartItem == null) { // Create a new cart item if no cart item exists cartItem = new Cart { AlbumId = album.AlbumId, CartId = ShoppingCartId, Count = 1, DateCreated = DateTime.Now }; _cartAppService.Create(cartItem); } else { // If the item does exist in the cart, then add one to the quantity cartItem.Count++; } }
public async Task <IHttpActionResult> Post(CartItemCreateOrUpdateDto input) { var result = await _service.Create(input); return(Ok(result)); }