public void Test_AttachmentUpdate_Validate() { var value = new AttachmentUpdate(); value.Validate(); Assert.AreEqual(1, value.Errors.Count, "Errors"); }
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); }