private CartProductDto MapCartProduct(CartItem ci, CartItemDto ciDto, CartProductDto cpDto, ResolutionContext rContext) { return(fixture.Generate <CartProductDto>(constraints: new { Id = ci.ProductId })); }
public async Task UpdateProductReturnsAddedCartProductFromApi() { var cartService = ResolveType <CartService>(); var newProduct = new CartProductDto { Id = 1, Quantity = 2 }; var product = await cartService.UpdateProduct(newProduct); Assert.AreEqual(newProduct.Quantity, product.Quantity); Assert.AreEqual(newProduct.Id, product.Id); }
public async Task <IActionResult> AddProductToCart(CartProductDto cartProductDto) { var cartId = await _repo.GetCartId(int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)); var cartProductToCreate = new ProductCart { CartId = cartId, ProductId = cartProductDto.Product.Id, Quantity = 1 }; var CreatedcartProduct = await _repo.AddToCart(cartProductToCreate); return(StatusCode(201)); }
public Response <CartDto> Add(Guid customerId, [FromUri] CartProductDto cartDto) { Response <CartDto> response = new Response <CartDto>(); try { response.Object = this.cartService.Add(customerId, cartDto); } catch (Exception ex) { //log error response.Errored = true; response.ErrorMessage = ex.Message; } return(response); }
public Response <CartDto> Add(AddProductToCartDto addProductToCart) { Guid customerId = addProductToCart.CustomerId; CartProductDto cartDto = new CartProductDto { ProductId = addProductToCart.ProductId, Quantity = addProductToCart.Quantity }; Response <CartDto> response = new Response <CartDto>(); try { response.Object = this.cartService.Add(customerId, cartDto); } catch (Exception ex) { //log error response.Errored = true; response.ErrorMessage = ex.Message; } return(response); }