public IActionResult Update(ProductMv product) { ViewBag.Categories = CategoryBus.GetAll().Result.Where(x => x.CategoryParent == TypeCategories.Child).ToList(); var productData = ProductBus.GetById(product.Id).Result; if (!ModelState.IsValid) { return(View(productData)); } product.ModifiedBy = Guid.Parse("a845b16a-4ca6-48e2-4ca6-08d817450c1a"); if (product.FileImage != null) { var ms = new MemoryStream(); product.FileImage.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); product.FileData = s; product.FileImage = null; } if (ProductBus.Update(product.Id, product).Result) { TempData[ConstKey.Success] = "Success!"; return(RedirectToAction("Index")); } TempData[ConstKey.Error] = "Fail! Try again."; return(View(productData)); }
public IActionResult Update(Guid id) { ViewBag.Categories = CategoryBus.GetAll().Result.Where(x => x.CategoryParent == TypeCategories.Child).ToList(); var product = ProductBus.GetById(id).Result; return(View(product)); }