public IActionResult UpdateGalleryCategory(CategoryImageUploadViewModel model) { if (!ModelState.IsValid) { ViewData["GeneralError"] = Messages.RequiredInput; return(View(model)); } CategoryImage categoryImage = new CategoryImage { Name = model.Name, Id = model.Id }; var result = _categoryImageService.Update(categoryImage); if (result.Success) { ViewData["GeneralSuccess"] = result.Message; return(RedirectToAction("ListGalleryCategory", "ManagementPanel")); } ViewData["GeneralError"] = Messages.GeneralError; return(View(model)); }
public IActionResult UpdateGalleryCategory(int id) { if (id == 0) { ViewData["GeneralError"] = Messages.GeneralError; return(RedirectToAction("ListGalleryCategory", "ManagementPanel")); } var data = _categoryImageService.GetById(id); if (data.Data != null) { CategoryImageUploadViewModel model = new CategoryImageUploadViewModel { Name = data.Data.Name, Id = data.Data.Id }; return(View(model)); } ViewData["GeneralError"] = Messages.GeneralError; return(RedirectToAction("ListGalleryCategory", "ManagementPanel")); }