public ActionResult Details(int id) { var projPMs = new List <ApplicationUser>(); Ticket Ticket = db.Tickets.Find(id); var projid = Ticket.ProjectId; var UsersOnProject = projectHelper.UsersOnProject(projid).ToList(); if (Ticket == null) { return(RedirectToAction("Oops4", "Home", null)); } foreach (var PmUser in UsersOnProject) { if (rolesHelper.IsUserInRole(PmUser.Id, "Project Manager")) { projPMs.Add(PmUser); } } var ProjectManager = projPMs.ToList(); ViewBag.Pms = new SelectList(ProjectManager, "Id", "DisplayName", projPMs); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses.Where(t => t.Name != "Unassigned" && t.Name != "Closed"), "Id", "Name", Ticket.TicketStatusId); return(View(Ticket)); }
public ActionResult Edit(int?id) { var userId = User.Identity.GetUserId(); Project project = db.Projects.Find(id); if (project == null) { return(HttpNotFound()); } var users = projectHelper.UsersOnProject(id ?? 0); var pmId = ""; var adminId = ""; var sub = ""; List <string> devIds = new List <string>(); foreach (var user in users) { if (rolerHelpers.IsUserInRole(user.Id, "Project Manager")) { pmId = user.Id; } if (rolerHelpers.IsUserInRole(user.Id, "Developer")) { devIds.Add(user.Id); } if (rolerHelpers.IsUserInRole(user.Id, "Admin")) { adminId = user.Id; } if (rolerHelpers.IsUserInRole(user.Id, "Submitter")) { sub = user.Id; } } var Submitter = rolerHelpers.UsersInRole("Submitter"); ViewBag.Submitter = new SelectList(Submitter, "Id", "Email", sub); var admin = rolerHelpers.UsersInRole("Admin"); ViewBag.Admin = new SelectList(admin, "Id", "Email", adminId); var pms = rolerHelpers.UsersInRole("Project Manager"); ViewBag.ProjectManager = new SelectList(pms, "Id", "Email", pmId); var dv = rolerHelpers.UsersInRole("Developer"); ViewBag.Developer = new MultiSelectList(dv, "Id", "Email", devIds); return(View(project)); }
public ActionResult ManageProjectUsers(int projectId, List <string> ProjectManagers, List <string> Developers, List <string> Submitters) { //Step 1: Remove all users from the project foreach (var user in projHelper.UsersOnProject(projectId).ToList()) { projHelper.RemoveUserFromProject(user.Id, projectId); } //Step 2: Adds back all the selected PM's if (ProjectManagers != null) { foreach (var projectManagerId in ProjectManagers) { projHelper.AddUserToProject(projectManagerId, projectId); } } //Step 3: Adds back all the selected Developers if (Developers != null) { foreach (var developerId in Developers) { projHelper.AddUserToProject(developerId, projectId); } } //Step 4: Adds back all the selected Submitters if (Submitters != null) { foreach (var submitterId in Submitters) { projHelper.AddUserToProject(submitterId, projectId); } } //Step 4: Redirect the user somewhere return(RedirectToAction("Details", "Projects", new { id = projectId })); }
public ActionResult ManageProjectUsers(int projectId, List <string> ProjectManagers, List <string> Developers, List <string> Submitters) { foreach (var user in projectHelper.UsersOnProject(projectId).ToList()) { projectHelper.RemoveUserFromProject(user.Id, projectId); } if (ProjectManagers != null) { foreach (var projectManagerId in ProjectManagers) { projectHelper.AddUserToProject(projectManagerId, projectId); } } if (Developers != null) { foreach (var DeveloperId in Developers) { projectHelper.AddUserToProject(DeveloperId, projectId); } } if (Submitters != null) { foreach (var SubmitterId in Submitters) { projectHelper.AddUserToProject(SubmitterId, projectId); } } return(RedirectToAction("Index", "Projects")); }
// GET: Tickets/Edit/5 public ActionResult Edit(int id) { Ticket ticket = db.Tickets.Find(id); var userId = User.Identity.GetUserId(); var proj = ticket.ProjectId; if (User.IsInRole("Submitter") && userId != ticket.OwnerUserId) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (User.IsInRole("Developer") && userId != ticket.AssignedToUserId) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var isuseronproject = projectHelper.IsUserOnProject(userId, proj); if (User.IsInRole("Project Manager") && !isuseronproject) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (ticket == null) { return(HttpNotFound()); } var projUsers = projectHelper.UsersOnProject(ticket.ProjectId); //var devs = projUsers.Where(B => UserRoleHelper.IsUserInRole(B.Id, "Developer")); var devs = projectHelper.UsersOnProjectWithRole("Developer", ticket.ProjectId); ViewBag.AssignedToUserId = new SelectList(devs, "Id", "Email", ticket.AssignedToUserId); if (User.IsInRole("Submitter")) { var projId = archivedHelper.GetMyActiveProjects(userId); ViewBag.ProjectId = new SelectList(projId, "Id", "Name", ticket.ProjectId); } else { var projId = archivedHelper.GetActiveProjects(); ViewBag.ProjectId = new SelectList(projId, "Id", "Name", ticket.ProjectId); } ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public ActionResult AssignProject(int project, string ProjectManager, List <string> Developers, List <string> Submitters) { if (ModelState.IsValid) { var projUsers = projHelper.UsersOnProject(project); foreach (var user in projUsers.ToList()) { projHelper.RemoveUserFromProject(user.Id, project); } if (User.IsInRole("Admin")) { projHelper.AddUserToProject(ProjectManager, project); } if (ProjectManager == null) { User.Identity.GetUserId(); } if (Developers != null) { foreach (var user in Developers) { projHelper.AddUserToProject(user, project); } } if (Submitters != null) { foreach (var user in Submitters) { projHelper.AddUserToProject(user, project); } } return(RedirectToAction("AP", "Projects")); } return(RedirectToAction("AP", "Projects")); }
public ActionResult AssignUser(int id) { Project project = db.Projects.Find(id); if (project == null) { return(RedirectToAction("Oops5", "Home", null)); } // 1. Setup a MultiSelectList to display all the Projects in our system var UsersOnProject = projectHelper.UsersOnProject(id); var projDevs = new List <string>(); var projSubs = new List <string>(); foreach (var devUser in UsersOnProject) { if (rolesHelper.IsUserInRole(devUser.Id, "Developer")) { projDevs.Add(devUser.Id); } } foreach (var subUser in UsersOnProject) { if (rolesHelper.IsUserInRole(subUser.Id, "Submitter")) { projDevs.Add(subUser.Id); } } var Developer = rolesHelper.UsersInRole("Developer"); ViewBag.Devs = new MultiSelectList(Developer, "Id", "DisplayName", projDevs); var Submitter = rolesHelper.UsersInRole("Submitter"); ViewBag.Subs = new MultiSelectList(Submitter, "Id", "DisplayName", projSubs); return(View(project)); }
public ActionResult ManageProjectUsers(List <int> projects, string projectManagerId, List <string> developers, List <string> submitters) { if (projects != null) { foreach (var projectId in projects) { //Remove everyone from this project foreach (var user in projectHelper.UsersOnProject(projectId).ToList()) { projectHelper.RemoveUserFromProject(user.Id, projectId); } //Add back PM if possible if (!string.IsNullOrEmpty(projectManagerId)) { projectHelper.AddUserToProject(projectManagerId, projectId); } if (developers != null) { foreach (var developerId in developers) { projectHelper.AddUserToProject(developerId, projectId); } } if (submitters != null) { foreach (var submitterId in submitters) { projectHelper.AddUserToProject(submitterId, projectId); } } } } return(RedirectToAction("ManageProjectUsers")); }
public ActionResult ManageProjectUsers(int id, string projectmanagers, List <string> msdevs, List <string> mssubs) { //Remove users from project if they are already on one. foreach (var user in projectHelper.UsersOnProject(id).ToList()) { //{ // projectHelper.RemoveUserFromProject(user.Id, id); //} //Add back PM if possible if (!string.IsNullOrEmpty(projectmanagers)) { projectHelper.AddProjectManagerToProject(projectmanagers, id); projectHelper.AddUserToProject(projectmanagers, id); } } if (msdevs != null) { foreach (var developerId in msdevs) { projectHelper.AddUserToProject(developerId, id); } } if (mssubs != null) { foreach (var submitterId in mssubs) { projectHelper.AddUserToProject(submitterId, id); } } //Remove everyone from this project //foreach (var user in projectHelper.UsersOnProject(model.Project.Id).ToList()) //{ // projectHelper.RemoveUserFromProject(user.Id, model.Project.Id); //} //Add back PM if possible // if (!string.IsNullOrEmpty(model.ProjectManager.Id)) // { // //projectHelper.AddUserToProject(projectManagerId, projectId); //projectHelper.AddProjectManagerToProject() // } // if (developers != null) // { // foreach(var developerId in developers) // { // projectHelper.AddUserToProject(developerId, projectId); // } // } // if (submitters != null) // { // foreach (var submitterId in submitters) // { // projectHelper.AddUserToProject(submitterId, projectId); // } // } // } //} return(RedirectToAction("ManageProjectUsers")); }