Пример #1
0
        public void Test_AttachmentUpdate_Validate()
        {
            var value = new AttachmentUpdate();

            value.Validate();

            Assert.AreEqual(1, value.Errors.Count, "Errors");
        }
Пример #2
0
        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);
        }