public ActionResult EditRole(UnifiedRoleView model) { if (ModelState.IsValid) { foreach (var user in db.Users.Where(u=>u.Email != "*****@*****.**" && u.Email != "*****@*****.**" && u.Email != "*****@*****.**" && u.Email != "*****@*****.**" && u.Email != "*****@*****.**")) { if (model.Selected != null && model.Selected.Contains(user.Id)) { helper.AddUserToRole(user.Id, model.RoleName); } else { helper.RemoveUserFromRole(user.Id, model.RoleName); } } } return RedirectToAction("EditRole", new { RoleName = model.RoleName }); }
//GET: Users/UserRoles EDIT public ActionResult EditRole(string RoleName, string querry) { var usersInRole = helper.UsersInRole(RoleName).Select(u => u.Id); var model = new UnifiedRoleView { RoleId = db.Roles.FirstOrDefault(r => r.Name == RoleName).Id, RoleName = RoleName, Users = new MultiSelectList(db.Users, "Id", "DisplayName", usersInRole), }; return View(model); }