public ActionResult Edit(Guid id) { Category category = _categorysService.Find(id); CategorysViewModel categorysViewModel = Mapper.Map <CategorysViewModel>(category); return(View("_EditCategorys", categorysViewModel)); }
public ActionResult Delete(Guid?id) { Category category = _categorysService.Find(id); CategorysViewModel categorysViewModel = Mapper.Map <CategorysViewModel>(category); return(PartialView("_DeleteCategorys", categorysViewModel)); }
public ActionResult Edit(CategorysViewModel categorysViewModel, HttpPostedFileBase image) { if (ModelState.IsValid) { Category oldCategory = _categorysService.Find(categorysViewModel.Id); if (oldCategory == null) { return(HttpNotFound()); } Category category = Mapper.Map <Category>(categorysViewModel); if (image != null) { if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true) { var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName); image.SaveAs(path); category.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName; } } else { if (oldCategory.Thumbnail != null) { category.Thumbnail = oldCategory.Thumbnail; } } _categorysService.Update(category, category.Id); return(RedirectToAction("Index")); } return(View(categorysViewModel)); }
public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Category category = _categorysService.Find(id); if (category == null) { return(HttpNotFound()); } CategorysViewModel categorysViewModel = Mapper.Map <CategorysViewModel>(category); return(View(categorysViewModel)); }
public ActionResult Create(CategorysViewModel categorysViewModel, HttpPostedFileBase image) { if (ModelState.IsValid) { categorysViewModel.Id = Guid.NewGuid(); Category category = Mapper.Map <Category>(categorysViewModel); if (image != null) { if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true) { var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName); image.SaveAs(path); category.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName; } } _categorysService.Create(category); return(RedirectToAction("Index")); } return(PartialView("_CreateCategorys", categorysViewModel)); }