コード例 #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var product   = _productDetail.GetById(id);
            int productId = product.Product.ProductID;
            await _productDetail.DeleteAsync(id);

            return(RedirectToAction("Index", new { id = productId }));
        }
コード例 #2
0
 public PartialViewResult _ErrorOrder(string idQty)
 {
     //check quantity prooduct
     if (idQty != null)
     {
         var           arr             = idQty.Split(' ');
         int           ProductDetailId = int.Parse(arr[0]);
         int           qty             = int.Parse(arr[1]);
         ProductDetail productDetail   = _productDetail.GetById(ProductDetailId);
         if (arr.Length > 2)
         {
             int qtyItem = int.Parse(arr[2]);
             if ((productDetail.Quantity - qty - qtyItem) < 0)
             {
                 ViewBag.message = "Hiện chỉ còn " + (productDetail.Quantity - qtyItem) + " sản phẩm!";
             }
         }
         else
         {
             if (productDetail.Quantity == 0)
             {
                 ViewBag.message = "Sản phẩm hiện đã hết hàng vui lòng chọn sản phẩm khác!";
             }
             else
             {
                 if (productDetail.Quantity <= qty)
                 {
                     if ((productDetail.Quantity - qty) >= 0)
                     {
                         ViewBag.message = "Hiện chỉ còn " + (productDetail.Quantity - qty) + " sản phẩm!";
                     }
                     else
                     {
                         ViewBag.message = "Hiện chỉ còn " + (productDetail.Quantity) + " sản phẩm!";
                     }
                 }
             }
         }
     }
     return(PartialView());
 }