예제 #1
0
        public ContentResult UpdateUserRoles(int userId, IEnumerable <int> roles)
        {
            var allRoles = identityLogic.GetRoles(new ListFilter()).Select(s => s.Id);

            foreach (var roleId in allRoles)
            {
                if ((roles != null) && (roles.Contains(roleId)))
                {
                    identityLogic.AddUserToRole(userId, roleId);
                }
                else
                {
                    identityLogic.RemoveUserFromRole(userId, roleId);
                }
            }

            return(Content(JsonConvert.SerializeObject("")));
        }