// GET: Projects/Edit/5
        public ActionResult Edit(int? id) {
            if (id == null) {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var projectId = db.ProjectsData.Find(id);
            var selected = projectId.Users.Select(u => u.Id);

            ProjectUsersModel projectUsersModel = new ProjectUsersModel() {
                Users = new MultiSelectList(db.Users, "Id", "DisplayName", selected),
                Project = projectId
            };
            return View(projectUsersModel);
        }
        // GET: Projects/Details/5
        // the "?" within the () is to allow you to catch any errors so you can give a friendly error instead.  
        // it tells the request to go through the action anyway
        public ActionResult Details(int? id) {
            if (id == null) {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var projectId = db.ProjectsData.Find(id);
            var selected = projectId.Users.Select(u => u.Id);
            var projectAssigned = projectId.Tickets.Where(t => t.TicketStatus.Name == "Assigned").Count();
            var projectUnassigned = projectId.Tickets.Where(t => t.TicketStatus.Name == "Unassigned").Count();
            var projectNeedsTesting = projectId.Tickets.Where(t => t.TicketStatus.Name == "Needs Testing").Count();

            ProjectUsersModel projectUsersModel = new ProjectUsersModel() {
                Users = new MultiSelectList(db.Users, "Id", "DisplayName", selected),
                Project = projectId
            };
            return View(projectUsersModel);
        }
        public ActionResult Edit(ProjectUsersModel projectUsersModel) {

            var project = db.ProjectsData.Find(projectUsersModel.Project.Id);

            UserProjectRolesHelper helper = new UserProjectRolesHelper();
            project.Users.Clear();

            foreach (var UserId in projectUsersModel.SelectedUsers) {

                    helper.AddUserToProject(UserId, project.Id);              
            }

            db.SaveChanges();
            return RedirectToAction("Index");
        }