Ejemplo n.º 1
0
        public async Task <CartResponse> Post([FromBody] Cart cart)
        {
            var cartresp = new CartResponse {
                Success = false
            };
            await context.Cart.AddAsync(cart);

            await context.SaveChangesAsync();

            cartresp.Success = true;
            cartresp.Message = "Cart Added Succesfully";


            return(cartresp);
        }
Ejemplo n.º 2
0
        public CartResponse UpdateCart([FromBody] Cart cart)
        {
            var cartResp = new CartResponse()
            {
                Success = false
            };

            if (context.Cart.Any(id => id.Id == cart.Id))
            {
                context.Cart.Remove(cart);
                context.SaveChanges();
                cartResp.Success = true;
                cartResp.Message = "cart deleted";
            }

            return(cartResp);
        }