예제 #1
0
        public ActionResult Update(AttachmentRuleCreateOrUpdate 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.CanUpdate(rule))
            {
                return NotAuthorized();
            }

            value.Validate();

            if (value.IsValid)
            {
                value.ValueToModel(rule);

                this.AttachmentRuleService.InsertOrUpdate(rule);

                value.SuccessMessage(Messages.AttachmentRuleUpdated.FormatInvariant(rule.FileType, rule.Group));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

            return base.View(Views.Update, value);
        }
예제 #2
0
        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();
        }