public ActionResult AddCategory(CategoryViewModel model) { if (SiteConfiguration.IsDemoMode) { DisplayMessage("You can't save changes in demo mode.", MessageType.Warning); return RedirectToAction("AddCategory"); } if (ModelState.IsValid) { var category = Mapper.Map<Category>(model); var result = adminService.AddCategory(category); if (result.Success) { DisplayMessage(Translations.Validations.ItemAdded, MessageType.OK); return RedirectToAction("Categories"); } else AddError(Translations.Validations.ErrorTryLater); } TempData["ModelState"] = ModelState; return RedirectToAction("AddCategory"); }
public ActionResult EditCategory(CategoryViewModel model, int id) { if (SiteConfiguration.IsDemoMode) { DisplayMessage("You can't save changes in demo mode.", MessageType.Warning); return RedirectToAction("EditCategory", new { id = id }); } if (ModelState.IsValid) { var category = Mapper.Map<Category>(model); category.UpdatedByUserID = CurrentUser.Id; var result = adminService.UpdateCategory(category); if (result.Success) DisplayMessage(Translations.Validations.ItemUpdated, MessageType.Information); else DisplayMessage(Translations.Validations.ErrorTryLater, MessageType.Error); } return RedirectToAction("EditCategory", new { id = id }); }
public ActionResult AddCategory() { var model = new CategoryViewModel(); model.CategoryCount = adminService.GetCategoryCount(); model.AvailableLanguages = adminService.GetAvailableLanguages(); model.SortOrder = model.CategoryCount; return View(model); }