//----------------------------------------------------- //Редактирование парфюма public ActionResult EditProduct(int ProductId) { Parfum product = productrepo.GetProductById(ProductId); ParfumViewModel obj = Mapper.Map <ParfumViewModel>(product); return(View(obj)); }
//----------------------------------------------------- //----------------------------------------------------- //Удаление категории //public ActionResult DeleteCategory(int CategoryId) //{ // Category obj = repo.GetAllCategoriesFromBase.FirstOrDefault(category => category.CategoryId == CategoryId); // TempData["message"] = repo.DeleteCategory(obj); // return RedirectToAction("Categories", "Admin"); //} //----------------------------------------------------- //----------------------------------------------------- //Добавление парфюма в категорию public ActionResult AddProduct(int CategoryId) { TempData["CategoryName"] = repo.GetCategoryName(CategoryId); ParfumViewModel model = new ParfumViewModel(); return(View(model)); }
public ActionResult EditProduct(ParfumViewModel obj, HttpPostedFileBase Image) { if (ModelState.IsValid) { if (Image != null) { obj.ImageMimeType = Image.ContentType; obj.ImageData = new byte[Image.ContentLength]; Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength); } Parfum p = Mapper.Map <Parfum>(obj); productrepo.SaveProduct(p); TempData["message"] = String.Format("Изменения в товаре '{0}' сохранены", obj.ProductName); return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId })); } else { return(View(obj)); } }
public ActionResult AddProduct(ParfumViewModel obj, HttpPostedFileBase Image) { if (ModelState.IsValid) { if (Image != null) { obj.ImageMimeType = Image.ContentType; obj.ImageData = new byte[Image.ContentLength]; Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength); } Parfum prod = Mapper.Map <Parfum>(obj); productrepo.SaveProduct(prod); TempData["message"] = String.Format("Товар '{0}' добавлен", obj.ProductName); return(RedirectToAction("Categories", "Admin")); } else { return(View(obj)); } }