public ActionResult AssignUsers(int Id) { var project = db.Projects.Find(Id); var user = new AssignUsersToProjVM(); user.Id = Id; user.userList = new MultiSelectList(db.Users, "Id", "FirstName", user.selectedUsers); user.projectName = project.Name; user.selectedUsers = projectHelper.ListUsersInProject(project.Id).ToList(); return(View(user)); }
public ActionResult AssignUsers(AssignUsersToProjVM model) { var x = db.Projects.Find(model.Id); foreach (var item in db.Users.Select(u => u.Id).ToList()) { projectHelper.RemoveProjectUser(x.Id, item); } foreach (var item in model.selectedUsers) { projectHelper.AssignProjectUser(x.Id, item); } return(RedirectToAction("Details", "Projects", new { id = model.Id })); }