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); }
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 Index(string group, int? page) { var query = new AttachmentRuleQuery(group, page); var rules = this.AttachmentRuleService.GetPaged(query.Specification); var rule = rules.FirstOrDefault(); var privilege = new AttachmentRulePrivilege(); return privilege.CanView(rule) ? base.View(Views.Index, rules) : NotAuthorized(); }
public ActionResult Update(int id) { var rule = this.AttachmentRuleService.GetById(id); if (rule == null) { return base.HttpNotFound(); } var privilege = new AttachmentRulePrivilege(); return privilege.CanUpdate(rule) ? base.View(Views.Update, new AttachmentRuleCreateOrUpdate(rule)) : NotAuthorized(); }
public ActionResult Delete(AttachmentRuleDelete value) { if (value == null) { throw new ArgumentNullException("value"); } var rule = this.AttachmentRuleService.GetById(value.Id); if (rule == null) { return base.HttpNotFound(); } var privilege = new AttachmentRulePrivilege(); if (!privilege.CanDelete(rule)) { return NotAuthorized(); } this.AttachmentRuleService.Delete(rule); return base.RedirectToRoute(AdministrationRoutes.AttachmentRuleIndex); }