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

            var staffViewModel = new StaffViewModel
            {
                project = db.projects.Include(i => i.constructionStaffs).First(i => i.projectID == id),
            };

            if (staffViewModel.project == null)
                return HttpNotFound();

            var allProjectStaffList = db.constructionStaffs.ToList();
            staffViewModel.AllProjectStaff = allProjectStaffList.Select(o => new SelectListItem
            {
                Text = o.userName,
                Value = o.staffID.ToString()
            });

            ViewBag.projectID = new SelectList(db.projects, "staffID", "FullName", staffViewModel.project.projectID);
            return View(staffViewModel);
        }
        public ActionResult Edit(StaffViewModel staffViewModel)
        {
            if (staffViewModel == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            if (ModelState.IsValid)
            {
                var jobToUpdate = db.projects
                    .Include(i => i.constructionStaffs).First(i => i.projectID == staffViewModel.project.projectID);

                if (TryUpdateModel(jobToUpdate, "Project", new string[] { "siteName", "projectID" }))
                {
                    var newJobTags = db.constructionStaffs.Where(
                        m => staffViewModel.SelectedConstructionStaff.Contains(m.staffID)).ToList();
                    var updatedJobTags = new HashSet<int>(staffViewModel.SelectedConstructionStaff);
                    foreach (constructionStaff jobTag in db.constructionStaffs)
                    {
                        if (!updatedJobTags.Contains(jobTag.staffID))
                        {
                            jobToUpdate.constructionStaffs.Remove(jobTag);
                        }
                        else
                        {
                            jobToUpdate.constructionStaffs.Add((jobTag));
                        }
                    }

                    db.Entry(jobToUpdate).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            ViewBag.ProjectID = new SelectList(db.projects, "projectID", "siteName", staffViewModel.project.projectID);
            return View(staffViewModel);
        }