示例#1
0
 /// <summary>
 /// Remove an Item from the shoping chart
 /// </summary>
 public HttpResponse <bool> RemoveItem(ShoppingCartCommand command)
 {
     return(new ApiHttpClient().DeleteRequest <bool>(ApiUrls.ShoppingRemoveItem, AppSettings.OAuthToken, command));
 }
示例#2
0
 /// <summary>
 /// Update an Item in the shoping chart
 /// </summary>
 public HttpResponse <bool> UpdateItem(ShoppingCartCommand command)
 {
     return(new ApiHttpClient().PutRequest <bool>(ApiUrls.ShoppingUpdateItem, AppSettings.OAuthToken, command));
 }
示例#3
0
        public async Task <ActionResult <ShoppingCartViewModel> > AddProductShoppingCartAsync(ShoppingCartCommand shoppingCartCommand)
        {
            var existingProduct = await _queries.FindByIdAsync(shoppingCartCommand.ProductId);

            var existingUser = await _userQueries.FindByUsernameAsync(shoppingCartCommand.Username);

            if (existingProduct == null || existingUser == null)
            {
                return(NotFound());
            }

            var existingProductInShoppingCart = await _shoppingCartQueries.FindByIdUsernameAsync(shoppingCartCommand.ProductId, shoppingCartCommand.Username);

            if (existingProductInShoppingCart != null)
            {
                return(Conflict());
            }

            var shoppingCart = _mapper.Map <ShoppingCart>(shoppingCartCommand);

            await _shoppingCartBehavior.CreateShoppingCartAsync(shoppingCart, existingProduct.Price);

            var shoppingCartViewModel = await _shoppingCartQueries.FindByIdAsync(shoppingCart.Id);

            return(shoppingCartViewModel);
        }