public async Task <IActionResult> Download(string sectionName) { // Gets list of sections and students from db for user to choose from var downloadCandidates = await SubmissionService.GetCheckpointDownloadCandidateListAsync( ClassroomName, ProjectName, CheckpointName); List <SectionsAndStudents> sectionStudents = downloadCandidates.Select ( dc => new SectionsAndStudents() { SectionId = dc.Section.Id, SectionName = new SelectListItem() { Text = dc.Section.DisplayName, Value = dc.Section.Name, // Whichever section the user had clicked on before // choosing to download should be checked by default Selected = (dc.Section.Name == sectionName) }, SelectedStudents = dc.Users.Select ( user => new StudentToDownload() { Selected = true, FirstName = user.User.FirstName, LastName = user.User.LastName, Id = user.User.Id, Submitted = user.Submitted } ) .OrderBy(ss => ss.LastName) .ThenBy(ss => ss.FirstName) .ToList() } ) .OrderBy(sas => sas.SectionName.Text) .ToList(); DownloadSubmissionViewModel viewModel = new DownloadSubmissionViewModel() { IndexForSectionStudentsView = -1, Format = ProjectSubmissionDownloadFormat.All, IncludeUnsubmitted = true, SectionsAndStudents = sectionStudents, }; return(View("Download", viewModel)); }