Esempio n. 1
0
        public ActionResult AddRoleInline(RoleModel model)
        {
            if (ModelState.IsValid)
            {
                Context.Roles.Add(new Role
                {
                    Name = model.Name,
                    Scope = model.Scope
                });

                Context.SaveChanges();
            }

            return PartialView("_AddRoleInline", model);
        }
Esempio n. 2
0
        public ActionResult EditRole(RoleModel model)
        {
            if (ModelState.IsValid)
            {
                Role role;
                if (!Context.Roles.TryGetById(model.Id, out role))
                    throw new InvalidOperationException(string.Format("role with id {0} was not found", model.Id));

                role.Name = model.Name;
                Context.SaveChanges();
            }

            return JsonView(ModelState.IsValid, "_EditRole", model);
        }
Esempio n. 3
0
        public ActionResult EditRole(long roleId)
        {
            Role role;
            if(!Context.Roles.TryGetById(roleId, out role))
                throw new InvalidOperationException(string.Format("role with id {0} was not found", roleId));

            var model = new RoleModel
            {
                Id = role.Id,
                Name = role.Name,
                Scope = role.Scope
            };

            return PartialView("_EditRole", model);
        }