Exemplo n.º 1
0
        public async Task <ActionResult> Edit([Bind(Include = "ProductDetailId,ProductName,Image,Price,Size,Color,Quantity,ProductID")] ProductDetail productDetail)
        {
            var f = Request.Files["ImageFile"];

            if (f != null && f.ContentLength > 0)
            {
                string FileName   = System.IO.Path.GetFileName(f.FileName);
                string UploadPath = Server.MapPath("~/wwwroot/images/" + FileName);
                f.SaveAs(UploadPath);
                productDetail.Image = FileName;
            }
            await _productDetail.UpdateAsync(productDetail);

            return(RedirectToAction("Index", new { id = productDetail.ProductID }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// the method cencell order
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ActionResult> CencellOrder(int id)
        {
            //update order
            Order orders = await _order.GetByIdAsync(id);

            orders.Status = Status.cancelled;
            await _order.UpdateAsync(orders);

            //update product quantity

            foreach (var orderDetail in orders.OrderDetails)
            {
                ProductDetail productDetail = await _productDetail.GetByIdAsync(orderDetail.ProductDetail.ProductDetailId);

                productDetail.Quantity += orderDetail.Quantity;
                await _productDetail.UpdateAsync(productDetail);
            }

            return(View(orders));
        }