public ActionResult Create(LanguageModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages)) return AccessDeniedView(); if (ModelState.IsValid) { var language = model.ToEntity(); _languageService.InsertLanguage(language); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Languages.Added")); return continueEditing ? RedirectToAction("Edit", new { id = language.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }
public ActionResult Edit(LanguageModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages)) return AccessDeniedView(); var language = _languageService.GetLanguageById(model.Id); if (language == null) //No language found with the specified id return RedirectToAction("List"); if (ModelState.IsValid) { //ensure we have at least one published language var allLanguages = _languageService.GetAllLanguages(); if (allLanguages.Count == 1 && allLanguages[0].Id == language.Id && !model.Published) { ErrorNotification("At least one published language is required."); return RedirectToAction("Edit", new { id = language.Id }); } //update language = model.ToEntity(language); _languageService.UpdateLanguage(language); //notification SuccessNotification(_localizationService.GetResource("Admin.Configuration.Languages.Updated")); return continueEditing ? RedirectToAction("Edit", new { id = language.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }