public SummaryModel getSummaryCohorts(int UserID, int? SelectedCohortID) { var userCohorts = db.ProgramCohorts.Select(e => new {Value = e.ProgramCohortID, Text = e.Program.ProgramTitle + " " + e.AcademicYear }); SummaryModel model = new SummaryModel() { ProgramCohorts = new SelectList(userCohorts, "Value", "Text", SelectedCohortID ?? userCohorts.First().Value), ProgramCohortID = SelectedCohortID ?? userCohorts.First().Value }; return model; }
public ActionResult Summary(SummaryModel post) { int? SelectedCohortID = post.ProgramCohortID == 0 ? (int?)null : post.ProgramCohortID; SummaryModel model = db.getSummaryCohorts(Convert.ToInt32(User.Identity.GetUserId()), SelectedCohortID); db.getSummaryCandidates(model); return View(model); }
public void getSummaryCandidates(SummaryModel model) { var candidates = db.CandidateEnrollments.Where(e => e.ProgramCohortID == model.ProgramCohortID).Select(e => new { Value = e.UserID, Text = e.User.LastName + ", " +e.User.FirstName}).OrderBy(c=> c.Text); model.Candidates = new SelectList(candidates, "Value", "Text"); }