Beispiel #1
0
        public ActionResult UpdateRoles(string username, string[] roles, string text, string role, int nbPage)
        {
            var existing = BLLUsers.ListUserRoles(username);
            var toAdd    = roles.Where(c => !existing.Any(d => d.Id == c));
            var toDelete = existing.Where(c => !roles.Contains(c.Id)).ToArray();

            BLLUsers.AddRolesToUser(username, toAdd.ToArray());
            BLLUsers.RemoveRolesToUser(username, toDelete.Select(c => c.Id).ToArray());

            return(RedirectToAction("UserList", new { text = text, role = role, nbPage = nbPage }));
        }