コード例 #1
0
        public void Test_AttachmentUpdate_Initialize()
        {
            var value = new AttachmentUpdate();

            value.Initialize(new Attachment());

            Assert.IsNotNull(value.Attachment, "Attachment");
        }
コード例 #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);
        }