コード例 #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));
        }
コード例 #2
0
 public ActionResult AddToBasket(string id)
 {
     basketService.AddBasket(this.HttpContext, id);
     return(RedirectToAction("Index"));
 }
コード例 #3
0
ファイル: BasketController.cs プロジェクト: mn808/MyShop1
 public ActionResult AddBasket(string Id) //Added the products = Id.
 {
     basketService.AddBasket(this.HttpContext, Id);
     return(RedirectToAction("Index"));
 }
コード例 #4
0
 public ActionResult <Basket> AddBasket(Basket Basket)
 {
     _service.AddBasket(Basket);
     return(Basket);
 }