public ActionResult RemoveUser(Project project, List <string> UsersOnProj) { foreach (var user in UsersOnProj) { userProjectHelper.RemoveUserFromProject(user, project.Id); } return(RedirectToAction("Details", "Projects", new { project.Id })); }
public ActionResult AssignUsers(int projectId, string managerId, List <string> submitterIds, List <string> developerIds) { if (User.IsInRole("Admin")) { // Dealing with PMs // Remove current PM and then add the selected PM var project = db.Projects.Find(projectId); project.ManagerId = managerId; db.SaveChanges(); } else { // Dealing with Subs and Devs // Remove all Subs on Project foreach (var user in assignHelper.UsersOnProjectInRole(projectId, "Submitter")) { projHelper.RemoveUserFromProject(user.Id, projectId); } // Add back all the selected Subs if (submitterIds != null) { foreach (var submitterId in submitterIds) { projHelper.AddUserToProject(submitterId, projectId); } } // Remove all Devs on Project foreach (var user in assignHelper.UsersOnProjectInRole(projectId, "Developer")) { projHelper.RemoveUserFromProject(user.Id, projectId); } // Add back all the selected Devs if (developerIds != null) { foreach (var developerId in developerIds) { projHelper.AddUserToProject(developerId, projectId); } } db.SaveChanges(); } return(RedirectToAction("Dashboard", "Home")); }
public ActionResult RemoveUsersFromProject(int pid, [Bind(Include = "usersOnProject,selectedUsersOnProject")] UserToProject model, string removeButton) { var helperProject = new UserProjectHelper(); foreach (var p in model.selectedUsersOnProject) { string userId = db.Users.FirstOrDefault(n => n.Id == p).Id; helperProject.RemoveUserFromProject(userId, pid); } return(RedirectToAction("ListProjectsAndUsers")); }
public ActionResult RemoveProjectsFromUser(string UserId, [Bind(Include = "assignedProjects,selectedAssignedProjects")] ProjectToUser model, string removeButton) { var userList = new List <ApplicationUser>(); var helperProject = new UserProjectHelper(); var ListOfProjects = db.Projects.OrderBy(p => p.Name).ToList().Select(pp => pp.Name.ToString()).ToList(); foreach (var p in model.selectedAssignedProjects) { int pId = db.Projects.FirstOrDefault(n => n.Name == p).Id; helperProject.RemoveUserFromProject(UserId, pId); } return(RedirectToAction("ListProjectsAndUsers")); }