public ActionResult AssignProjectManager(int id) { var project = db.Projects.Find(id); var model = new AssignProjectManagersViewModel { ProjectId = id, ProjectName = project.Name }; var userProjectList = helper.ListManagersNotOnProject(id); model.Users = new MultiSelectList(userProjectList.OrderBy(m => m.FirstName), "Id", "FirstName", null); return(View(model)); }
public ActionResult AssignProjectManager(AssignProjectManagersViewModel model) { if (ModelState.IsValid) { if (model.SelectedUsers != null) { var user = helper.GetProjectManager(model.ProjectId); if (user != null) { helper.RemoveUserFromProject(user.Id, model.ProjectId); } helper.AssignUserToProject(model.SelectedUsers[0], model.ProjectId); } return(RedirectToAction("PMAssignations", "ProjectManagers", new { id = model.ProjectId })); } return(View(model)); }