// GET: Instructor/Create public ActionResult Create() { var instructor = new Instructor(); instructor.AssessmentTools = new List<AssessmentTool>(); PopulateAssignedAssessmentData(instructor); //PopulateUnitDropDownList(); return View(); }
private void UpdateInstructorAssessment(string[] selectedUnits, Instructor instructorToUpdate) { if (selectedUnits == null) { instructorToUpdate.AssessmentTools = new List<AssessmentTool>(); return; } var selectedUnitsHS = new HashSet<string>(selectedUnits); var instructorUnits = new HashSet<string>(instructorToUpdate.Units.Select(c => c.ToString())); foreach (var unit in db.Units) { if (selectedUnitsHS.Contains(unit.UnitCode.ToString())){ if (!instructorUnits.Contains(unit.UnitCode)) { instructorToUpdate.Units.Add(unit) ; } } else { if (instructorUnits.Contains(unit.UnitCode)) { instructorToUpdate.Units.Remove(unit); } } } }
private void PopulateAssignedAssessmentData(Instructor instructor) { var allAssessments = db.Assessments; //var instructorAssessments = new HashSet<string>(instructor.AssessmentTools.Select(a => a.Id)); var viewModel = new List<InstructorIndexData>(); foreach (var tools in allAssessments) { viewModel.Add(new InstructorIndexData { UnitCode = new List<Unit>(), }); } ViewBag.Instrutors = viewModel; }