public async Task <IActionResult> EditProduct(ViewModels.PM.Product.EditProductViewModel editProductViewModel) { string ImagePath = null;; ImageErrorModel imageErrorModel = new ImageErrorModel(); if (editProductViewModel.DefaultImage == null) { ImagePath = editProductViewModel.OldImage; } else { ImagePath = UploadImage(editProductViewModel.DefaultImage, ref imageErrorModel); } if (ModelState.IsValid) { Product objProduct = await this.ProductBLL.Find(editProductViewModel.ID); objProduct.ID = editProductViewModel.ID; objProduct.Specification = editProductViewModel.Specification; objProduct.DefaultImage = ImagePath; objProduct.Price = editProductViewModel.DefauftPrice; objProduct.isOnlineOnly = editProductViewModel.isOnlineOnly; objProduct.StockMin = editProductViewModel.StockMin; objProduct.Details = editProductViewModel.Details; objProduct.IsAllowComment = editProductViewModel.IsAllowComment; objProduct.CreatedTime = editProductViewModel.CreateTime; objProduct.BrandID = editProductViewModel.Brand; objProduct.CategoryID = editProductViewModel.Category; objProduct.SubGroupID = editProductViewModel.SubGroup; await ProductBLL.Update(objProduct); return(RedirectToAction("Index")); } return(View(editProductViewModel)); }
public async Task <IActionResult> EditProduct(string id) { Product objproduct = await this.ProductBLL.Find(id); ViewModels.PM.Product.EditProductViewModel editProductViewModel = new ViewModels.PM.Product.EditProductViewModel { OldImage = objproduct.DefaultImage, DefauftPrice = objproduct.Price, //DefaultImage=objproduct.DefaultImage, SubGroup = objproduct.SubGroupID, Category = objproduct.CategoryID, Brand = objproduct.BrandID, IsAllowComment = objproduct.IsAllowComment, CreateTime = objproduct.CreatedTime }; return(View(editProductViewModel)); }