public ActionResult Edit(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} Project project = db.Projects.Find(id); if (project == null) { return(HttpNotFound()); } if (!(projectHelper.IsUserOnProject(User.Identity.GetUserId(), project.Id) && User.IsInRole("Project Manager")) && !(User.IsInRole("Administrator"))) { return(HttpNotFound()); } ViewBag.UserOn = new MultiSelectList(projectHelper.UsersInProjNotInRole(id, "Project Manager"), "Id", "UserName"); ViewBag.UserOff = new MultiSelectList(projectHelper.UsersNotOnProjOrInRole(id, "Project Manager"), "Id", "UserName"); foreach (var pm in userHelper.UsersInRole("Project Manager")) { if (projectHelper.IsUserOnProject(pm.Id, id)) { ViewBag.CurrentPm = pm.UserName; } } ViewBag.PMs = new SelectList(userHelper.UsersInRole("Project manager"), "Id", "UserName"); return(View(project)); }