public ActionResult ChangeRole(string id) { if (id != null) { var FindUser = db.Users.Find(id); var RolesRoom = new UserViewModel(); UserRolesHelper userRole = new UserRolesHelper(db); RolesRoom.FirstName = FindUser.FirstName; RolesRoom.LastName = FindUser.LastName; RolesRoom.Id = FindUser.Id; RolesRoom.SelectedRoles = userRole.ListUseRoles(id).ToArray(); RolesRoom.Roles = new MultiSelectList(db.Roles, "Name", "Name", RolesRoom.SelectedRoles); return(View(RolesRoom)); } var projects = db.Projects.Include(t => t.Name).Include(t => t.Id); return(RedirectToAction("Index")); }
public ActionResult Index() { List <AdminUserViewModel> roleusers = new List <AdminUserViewModel>(); UserRolesHelper userRole = new UserRolesHelper(db); var AdminModel = new UserViewModel(); foreach (var RoleUser in db.Users.ToList()) { var roleuser = new AdminUserViewModel(); roleuser.roles = userRole.ListUseRoles(RoleUser.Id); roleuser.Name = db.Roles.Find(roleuser.roles.FirstOrDefault()); roleuser.user = RoleUser; roleusers.Add(roleuser); } return(View(roleusers)); }