private void PopulateAssignedSkillData(Staff staff)
 {
     var allSkills = db.Skills;
     var staffSkills = new HashSet<int>(staff.Skills.Select(s => s.ID));
     var viewModel = new List<AssignedSkillData>();
     foreach (var skill in allSkills)
     {
         viewModel.Add(new AssignedSkillData
         {
             SkillID = skill.ID,
             Title = skill.Name,
             Assigned = staffSkills.Contains(skill.ID)
         });
     }
     ViewBag.Skills = viewModel;
 }
 private void UpdateStaffSkills(string[] selectedSkills, Staff staff)
 {
     if (selectedSkills == null)
     {
         staff.Skills = new List<Skill>();
     }
     var selectedSkillsHS = new HashSet<string>(selectedSkills);
     var staffSkills = new HashSet<int>(staff.Skills.Select(s => s.ID));
     foreach (var skill in db.Skills)
     {
         if (selectedSkillsHS.Contains(skill.ID.ToString()))
         {
             if (!staffSkills.Contains(skill.ID))
             {
                 staff.Skills.Add(skill);
             }
         }
         else
         {
             if (staffSkills.Contains(skill.ID))
             {
                 staff.Skills.Remove(skill);
             }
         }
     }
 }
        public async Task<ActionResult> Edit(Staff staff)
        {
            Staff f = db.StaffList.Find(staff.ID);
            f.SSN = staff.SSN;
            f.NamePrefix = staff.NamePrefix;
            f.FirstName = staff.FirstName;
            f.MiddleName = staff.MiddleName;
            f.LastName = staff.LastName;
            f.NameSuffix = staff.NameSuffix;
            f.DateOfBirth = staff.DateOfBirth;
            f.RankDate = staff.RankDate;
            f.CareerDevelopmentDate = staff.CareerDevelopmentDate;
            f.EmploymentDate = staff.EmploymentDate;
            f.TerminationDate = staff.TerminationDate;
            f.MilitaryLeave = staff.MilitaryLeave;
            f.RosterRank = staff.RosterRank;
            f.HenricoUserID = staff.HenricoUserID;
            f.OracleHrID = staff.OracleHrID;
            f.BadgeNumber = staff.BadgeNumber;
            f.Gender_ID = staff.Gender_ID;
            f.Race_ID = staff.Race_ID;
            f.CDL_ID = staff.CDL_ID;

            if (ModelState.IsValid)
            {
                f.UpdatedOn = DateTime.Now;
                db.Entry(f).State = EntityState.Modified;
                await db.SaveChangesAsync();
                return RedirectToAction("Details", "Staff", new { id = f.ID });
            }
            return View(f);
        }