public async Task <IActionResult> Index(HomeViewModel model = null) { model ??= new HomeViewModel(); var lookups = await _lookupApiService.GetLookups(); model.Lookups = lookups; return(View(model)); }
public async Task <IActionResult> Search([FromForm] TSearchModel searchModel) { if (searchModel.SearchType.HasValue && _searchType != searchModel.SearchType) { return(RedirectToNewSearch(searchModel)); } var model = new SearchResultsViewModel <TSearchModel, TResults>(); ValidateSearch(searchModel, model); if (model.ValidationErrors.Any()) { model.SearchModel = searchModel; model.LookUpModel = await _lookupApiService.GetLookups(); return(View("Index", model)); } model = await PopulateViewModel(null, searchModel); return(View("Index", model)); }
private async Task <LearningAimDetailsViewModel> GetData(string learnAimRef, string academicYear = null) { var lookupsTask = _lookupApiService.GetLookups(); var learningAimTask = _learningAimsApiService.GetLearningAim(learnAimRef); await Task.WhenAll(lookupsTask, learningAimTask); var lookups = lookupsTask.Result; var learningAim = learningAimTask.Result; var selectedYear = academicYear ?? lookups.AcademicYearLookups.FirstOrDefault(l => l.IsCurrentAcademicYear)?.AcademicYear; return(new LearningAimDetailsViewModel { AcademicYear = selectedYear, LookUpModel = lookups, LearningAimModel = learningAim, FormController = FormController, CategoryController = CategoryController }); }