public ActionResult Create() { if (!User.IsInRole("Admin")) { return RedirectToAction("Index", "Home"); } var helper = new UserRolesHelper(db); var managers = helper.UsersInRole("ProjectManager").ToList(); ViewBag.ManagerId = new SelectList(managers, "Id", "Name"); return View(); }
public ActionResult RemoveUsers(int id) { var helper = new UserRolesHelper(db); var managers = helper.UsersInRole("ProjectManager").ToList(); var developers = helper.UsersInRole("Developer").ToList(); var currentproject = db.Projects.Single(p => p.Id == id); var project = new ProjectUsersViewModel { ProjectId = currentproject.Id, Name = currentproject.Name, Description = currentproject.Description, ProjectDevelopers = currentproject.Developers.ToList(), ProjectManager = currentproject.Manager, CurrentDevelopers = currentproject.Developers.Select(d => d.Id).ToArray(), AvailableDevelopers = new SelectList(developers, "Id", "Name"), }; return View(project); }
public ActionResult Edit(int? id) { if (!User.IsInRole("Admin")) { return RedirectToAction("Index", "Home"); } if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Project project = db.Projects.Find(id); if (project == null) { return HttpNotFound(); } var helper = new UserRolesHelper(db); var managers = helper.UsersInRole("ProjectManager").ToList(); ViewBag.ManagerId = new SelectList(managers, "Id", "Name", project.ManagerId); return View(project); }