public ActionResult Create() { var role = this.UserRoleService.Create(); var privilege = new UserRolePrivilege(); return privilege.CanCreate(role) ? base.View(Views.Create, new UserRoleCreateOrUpdate()) : NotAuthorized(); }
public ActionResult Create(UserRoleCreateOrUpdate value, IList<UserRoleRelationUpdateValue> privileges) { if (value == null) { throw new ArgumentNullException("value"); } var role = this.UserRoleService.Create(); var privilege = new UserRolePrivilege(); if (!privilege.CanCreate(role)) { return NotAuthorized(); } value.Validate(); if (value.IsValid) { value.ValueToModel(role); this.UserRoleService.InsertOrUpdate(role, privileges); value = new UserRoleCreateOrUpdate(role); value.SuccessMessage(Messages.UserRoleCreated.FormatInvariant(role.Title)); } else { value.CopyToModel(ModelState); } return base.View(Views.Update, value); }