public ActionResult Create() { var rule = this.AttachmentRuleService.Create(); var privilege = new AttachmentRulePrivilege(); return privilege.CanCreate(rule) ? base.View(Views.Create, new AttachmentRuleCreateOrUpdate()) : NotAuthorized(); }
public ActionResult Create(AttachmentRuleCreateOrUpdate value) { if (value == null) { throw new ArgumentNullException("value"); } var rule = this.AttachmentRuleService.Create(); var privilege = new AttachmentRulePrivilege(); if (!privilege.CanCreate(rule)) { return NotAuthorized(); } value.Validate(); if (value.IsValid) { value.ValueToModel(rule); this.AttachmentRuleService.InsertOrUpdate(rule); value = new AttachmentRuleCreateOrUpdate(rule); value.SuccessMessage(Messages.AttachmentRuleCreated.FormatInvariant(rule.FileType, rule.Group)); } else { value.CopyToModel(ModelState); } return base.View(Views.Update, value); }