public void AssignUserToProject(ProjectUserViewModel model)
 {
     Project project = FindProject(model.Project.Id);
     project.Users.Clear();
     project.Users = db.Users.Where(u => model.SelectedUsers.Contains(u.Id)).ToList();
     db.SaveChanges();
 }
 public ActionResult Edit(ProjectUserViewModel model)
 {
     db.Projects.Attach(model.Project);
     db.Entry(model.Project).Property("Name").IsModified = true;
     db.SaveChanges();
     return RedirectToAction("Edit", new { Id = model.Project.Id });
 }
        public ActionResult Edit(int? Id)
        {
            UserRoleHelper helper = new UserRoleHelper();
            var pms = helper.UsersInRole("Project Manager");
            var devs = helper.UsersInRole("Developer");
            var project = db.Projects.Find(Id);
            var model = new ProjectUserViewModel()
            {
                Project = project,
               Pms = new MultiSelectList(pms, "Id", "UserName", project.Users.Select(u => u.Id)),
                Devs = new MultiSelectList(devs, "Id", "UserName", project.Users.Select(u => u.Id)),
                Ticket = null,

            };
            return View(model);
        }
 public ActionResult AssignPm(ProjectUserViewModel model)
 {
     PHelper.AssignUserToProject(model);
     return RedirectToAction("Edit", new{Id = model.Project.Id });
 }