public ActionResult Delete(int id) { var attachment = this.AttachmentService.GetById(id); if (attachment == null) { return base.HttpNotFound(); } var privilege = new AttachmentPrivilege(); return privilege.CanDelete(attachment) ? base.View(Views.Delete, new AttachmentDelete(attachment)) : NotAuthorized(); }
public ActionResult Delete(AttachmentDelete value) { if (value == null) { throw new ArgumentNullException("value"); } var attachment = this.AttachmentService.GetById(value.Id); if (attachment == null) { return base.HttpNotFound(); } var privilege = new AttachmentPrivilege(); if (!privilege.CanDelete(attachment)) { return NotAuthorized(); } this.AttachmentService.Delete(attachment, value.Soft); return base.RedirectToRoute(AdministrationRoutes.AttachmentIndex); }
public ActionResult Update(AttachmentUpdate value) { if (value == null) { throw new ArgumentNullException("value"); } var attachment = this.AttachmentService.GetById(value.Id); if (attachment == null) { return base.HttpNotFound(); } var privilege = new AttachmentPrivilege(); if (!privilege.CanUpdate(attachment)) { return NotAuthorized(); } value.Validate(); if (value.IsValid) { value.ValueToModel(attachment); this.AttachmentService.Update(attachment); value.SuccessMessage(Messages.AttachmentUpdated); } else { value.CopyToModel(ModelState); } value.Initialize(attachment); return base.View(Views.Update, value); }
public ActionResult Index(string type, string status, SortAttachment sort, SortOrder order, int? page) { var query = new AttachmentQuery(type, status, sort, order, page); var attachments = this.AttachmentService.GetPaged(query.Specification); var attachment = attachments.FirstOrDefault(); var privilege = new AttachmentPrivilege(); return privilege.CanView(attachment) ? base.View(Views.Index, attachments) : NotAuthorized(); }