Exemplo n.º 1
0
        public IActionResult AddItem(string productId, string customerName, int quantity)
        {
            if (productId == null)
            {
                return(NotFound());
            }

            Product item = productService.Get(productId);

            if (item.TotalUnit >= quantity)
            {
                try
                {
                    basketService.AddBasket(item, customerName, quantity);
                }
                catch (Exception err)
                {
                    return(BadRequest(err.Message));
                }
            }
            else
            {
                return(NotFound("There is no item in stock"));
            }

            return(Ok(productId));
        }
Exemplo n.º 2
0
 public ActionResult AddToBasket(string id)
 {
     basketService.AddBasket(this.HttpContext, id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 3
0
 public ActionResult AddBasket(string Id) //Added the products = Id.
 {
     basketService.AddBasket(this.HttpContext, Id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
 public ActionResult <Basket> AddBasket(Basket Basket)
 {
     _service.AddBasket(Basket);
     return(Basket);
 }