public virtual ActionResult Save(SectionViewModel model) { if (ModelState.IsValid) { var section = sectionService.Find(model.Id); if (section == null || !permissionService.IsAllowed((Int32)SectionOperations.Manage, this.CorePrincipal(), typeof(Section), section.Id, IsSectionOwner(section), PermissionOperationLevel.Object)) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } if (sectionService.Save(model.MapTo(section))) { //save locale var localeService = ServiceLocator.Current.GetInstance <ISectionLocaleService>(); SectionLocale locale = localeService.GetLocale(section.Id, model.SelectedCulture); locale = model.MapLocaleTo(locale ?? new SectionLocale { Section = section }); localeService.Save(locale); Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(WebContentMVC.Section.Edit(model.Id))); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } model.AllowManage = true; return(View("Edit", model)); }
public virtual ActionResult New(SectionViewModel section) { if (ModelState.IsValid) { var newSection = section.MapTo(new Section { UserId = this.CorePrincipal() != null ? this.CorePrincipal().PrincipalId : (long?)null }); if (sectionService.Save(newSection)) { permissionService.SetupDefaultRolePermissions(OperationsHelper.GetOperations <SectionOperations>(), typeof(Section), newSection.Id); Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(WebContentMVC.Section.Show())); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } section.AllowManage = true; return(View("New", section)); }
public virtual ActionResult New(SectionViewModel section) { if (ModelState.IsValid) { var newSection = section.MapTo(new Section { UserId = this.CorePrincipal() != null ? this.CorePrincipal().PrincipalId : (long?)null }); if (sectionService.Save(newSection)) { permissionService.SetupDefaultRolePermissions(OperationsHelper.GetOperations<SectionOperations>(), typeof(Section), newSection.Id); Success(HttpContext.Translate("Messages.Success", String.Empty)); return RedirectToAction(WebContentMVC.Section.Show()); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } section.AllowManage = true; return View("New", section); }
public virtual ActionResult Save(SectionViewModel model) { if (ModelState.IsValid) { var section = sectionService.Find(model.Id); if (section == null || !permissionService.IsAllowed((Int32)SectionOperations.Manage, this.CorePrincipal(), typeof(Section), section.Id, IsSectionOwner(section), PermissionOperationLevel.Object)) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } if (sectionService.Save(model.MapTo(section))) { //save locale var localeService = ServiceLocator.Current.GetInstance<ISectionLocaleService>(); SectionLocale locale = localeService.GetLocale(section.Id, model.SelectedCulture); locale = model.MapLocaleTo(locale ?? new SectionLocale { Section = section }); localeService.Save(locale); Success(HttpContext.Translate("Messages.Success", String.Empty)); return RedirectToAction(WebContentMVC.Section.Edit(model.Id)); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } model.AllowManage = true; return View("Edit", model); }