public async Task <IViewComponentResult> InvokeAsync(TrainingProviderDetailQueryViewModel searchQueryModel, ViewType viewType = ViewType.Details) { searchQueryModel.ApprenticeshipType = _apprenticeshipOrchestrator.GetApprenticeshipType(searchQueryModel.ApprenticeshipId); searchQueryModel.ViewType = viewType; var model = await _tpOrchestrator.GetDetails(searchQueryModel); model.SearchQuery = searchQueryModel; if (searchQueryModel.ApprenticeshipType == ApprenticeshipType.Standard) { model.Apprenticeship = await _apprenticeshipOrchestrator.GetStandard(searchQueryModel.ApprenticeshipId); } else { model.Apprenticeship = await _apprenticeshipOrchestrator.GetFramework(searchQueryModel.ApprenticeshipId); } switch (searchQueryModel.ViewType) { case ViewType.Contact: return(View("../TrainingProvider/Details/Contact", model)); case ViewType.Summary: return(View("../TrainingProvider/Details/Summary", model)); case ViewType.Details: default: return(View("../TrainingProvider/Details/Default", model)); } }
public async Task <IViewComponentResult> InvokeAsync(TrainingProviderDetailQueryViewModel providerDetailsQueryModel, TrainingProviderSearchViewModel searchQueryModel, string title = "Training provider results") { if (providerDetailsQueryModel != null) { providerDetailsQueryModel.ApprenticeshipType = _apprenticeshipOrchestrator.GetApprenticeshipType(providerDetailsQueryModel.ApprenticeshipId); var model = await _tpOrchestrator.GetDetails(providerDetailsQueryModel); model.SearchQuery = providerDetailsQueryModel; return(View("../TrainingProvider/Title/Default", model.Name)); } else { var result = await _tpOrchestrator.GetSearchResults(searchQueryModel); switch (result.Status) { case ProviderSearchResponseCodes.ScotlandPostcode: return(View("../TrainingProvider/Title/Scotland")); case ProviderSearchResponseCodes.WalesPostcode: return(View("../TrainingProvider/Title/Wales")); case ProviderSearchResponseCodes.NorthernIrelandPostcode: return(View("../TrainingProvider/Title/NorthernIreland")); case ProviderSearchResponseCodes.PostCodeInvalidFormat: return(View("../TrainingProvider/Title/NonUK")); default: return(View("../TrainingProvider/Title/Default", title)); } } }