Exemple #1
0
        public ActionResult Update(UserRoleCreateOrUpdate value, IList<UserRoleRelationUpdateValue> privileges)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var role = this.UserRoleService.GetById(value.Id);

            if (role == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserRolePrivilege();

            if (!privilege.CanUpdate(role))
            {
                return NotAuthorized();
            }

            value.Validate();

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

                this.UserRoleService.InsertOrUpdate(role, privileges);

                value.SuccessMessage(Messages.UserRoleUpdated.FormatInvariant(role.Title));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

            return base.View(Views.Update, value);
        }
Exemple #2
0
        public ActionResult Update(int id)
        {
            var role = this.UserRoleService.GetById(id);

            if (role == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserRolePrivilege();

            return privilege.CanUpdate(role) ? base.View(Views.Update, new UserRoleCreateOrUpdate(role)) : NotAuthorized();
        }