private void UpdateInstructorAssessment(string[] selectedAssessment, AssessmentTool assessmentToUpdate) { if(selectedAssessment == null) { assessmentToUpdate.Instructors = new List<Instructor>(); return; } var selectedAssessmentHS = new HashSet<string>(selectedAssessment); var assessmentInstructors = new HashSet<string>(assessmentToUpdate.Instructors.Select(a => a.ToString())); foreach(var instr in db.Instructors) { if (selectedAssessmentHS.Contains(instr.LastName.ToString())) { if(!assessmentInstructors.Contains(instr.LastName)) { assessmentToUpdate.Instructors.Add(instr); } } else { if (assessmentInstructors.Contains(instr.LastName)) { assessmentToUpdate.Instructors.Remove(instr); } } } }
private void PopulateAssignedAssessmentData(AssessmentTool assessmentTool) { var allAssessments = db.Assessments; // var instructorAssessment = new HashSet<string>(assessmentTool.Instructors.Select(a => a.Id)); var viewModel = new List<AssessmentIndexData>(); foreach (var tool in allAssessments) { viewModel.Add(new AssessmentIndexData { AssessmentTasks = new List<AssessmentTask>(), UnitCode = new List<Unit>(), Qualifications = new List<Qualification>(), AssessmentTools = new List<AssessmentTool>() }); } ViewBag.AssessmentTools = viewModel; }