public HttpResponseMessage GetRightsByRole(PermissionsViewModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.IdRole))
                {
                    model.success = "true";
                    return(this.Request.CreateResponse <PermissionsViewModel>(HttpStatusCode.OK, model));
                }
                else
                {
                    int             id   = int.Parse(model.IdRole);
                    ApplicationRole role = ApplicationRoleManager.GetRole(id);
                    model.success     = "true";
                    model.ListDiritti = role.PERMISSIONS.ToList();
                    model.Totale      = role.PERMISSIONS.Count.ToString();
                }
            }

            catch (Exception ex)
            {
                model.success = "false";
                model.message = ex.Message;
            }
            return(this.Request.CreateResponse <PermissionsViewModel>(HttpStatusCode.OK, model));
        }
Beispiel #2
0
        public ActionResult RoleDetails()
        {
            var id = HttpContext.Request.QueryString["id"].First();

            ViewBag.GroupId = id;
            ApplicationRole model = ApplicationRoleManager.GetRole(id);

            return(View(model));
        }
        public ActionResult RoleEdit(int id)
        {
            ApplicationRole _role = ApplicationRoleManager.GetRole(id);

            // USERS combo
            ViewBag.UserId = new SelectList(ApplicationUserManager.GetUsers4SelectList(), "Id", "Username");
            ViewBag.RoleId = id;

            // Rights combo
            ViewBag.PermissionId       = new SelectList(ApplicationRoleManager.GetPermissions4SelectList(), "PermissionId", "PermissionDescription");
            ViewBag.List_boolNullYesNo = this.List_boolNullYesNo();

            return(View(_role));
        }
Beispiel #4
0
        public ViewResult RoleDetails(int id)
        {
            ApplicationRole _role = ApplicationRoleManager.GetRole(id);
            RoleViewModel   model = new RoleViewModel();

            if (_role != null)
            {
                model.Id              = _role.Id;
                model.RoleName        = _role.Name;
                model.RoleDescription = _role.RoleDescription;
            }
            // USERS combo
            ViewBag.UserId = new SelectList(ApplicationUserManager.GetUsers4SelectList(), "Id", "UserName");
            ViewBag.RoleId = id;

            // Rights combo
            ViewBag.PermissionId       = new SelectList(ApplicationRoleManager.GetPermissions4SelectList(), "PermissionId", "PermissionDescription");
            ViewBag.List_boolNullYesNo = this.List_boolNullYesNo();

            return(View(model));
        }
 public PartialViewResult DeletePermissionFromRoleReturnPartialView(int id, int permissionId)
 {
     ApplicationRoleManager.RemovePermission4Role(id, permissionId);
     return(PartialView("_ListPermissions", ApplicationRoleManager.GetRole(id)));
 }
 public PartialViewResult AddAllPermissions2RoleReturnPartialView(int id)
 {
     ApplicationRoleManager.AddAllPermissions2Role(id);
     return(PartialView("_ListPermissions", ApplicationRoleManager.GetRole(id)));
 }
 public PartialViewResult AddUser2RoleReturnPartialView(int id, int userId)
 {
     ApplicationUserManager.AddUser2Role(userId, id);
     return(PartialView("_ListUsersTable4Role", ApplicationRoleManager.GetRole(id)));
 }
 public PartialViewResult DeleteUserFromRoleReturnPartialView(int id, int userId)
 {
     ApplicationUserManager.RemoveUser4Role(userId, id);
     return(PartialView("_ListUsersTable4Role", ApplicationRoleManager.GetRole(id)));
 }