private async Task <Standard> GetStandard(long standardCode) { try { var standardsView = _inProcessCache.Get <StandardsView>(nameof(StandardsView)); if (standardsView != null) { return(standardsView.Standards?.SingleOrDefault(s => s.Code.Equals(standardCode))); } standardsView = await _apprenticeshipInfoService.GetStandardsAsync(); if (standardsView != null) { _inProcessCache.Set(nameof(StandardsView), standardsView, new TimeSpan(1, 0, 0)); } return(standardsView?.Standards?.SingleOrDefault(s => s.Code.Equals(standardCode))); } catch (Exception e) { _logger.Warn(e, "Could not get standards from apprenticeship API."); } return(null); }
public async Task <GetStandardsQueryResponse> Handle(GetStandardsQueryRequest message) { var data = await _apprenticeshipInfoServiceWrapper.GetStandardsAsync(); return(new GetStandardsQueryResponse { Standards = data.Standards }); }
private async Task <Standard> GetStandard(long standardCode) { try { var standardsView = await _apprenticeshipInfoService.GetStandardsAsync(); return(standardsView.Standards.SingleOrDefault(s => s.Code.Equals(standardCode))); } catch (Exception e) { _logger.Warn(e, "Could not get standards from apprenticeship API."); } return(null); }
public async Task <GetTrainingProgrammesQueryResponse> Handle(GetTrainingProgrammesQueryRequest message) { var standardsTask = _apprenticeshipInfoServiceWrapper.GetStandardsAsync(); var frameworksTask = _apprenticeshipInfoServiceWrapper.GetFrameworksAsync(); await Task.WhenAll(standardsTask, frameworksTask); var programmes = standardsTask.Result.Standards.Union(frameworksTask.Result.Frameworks.Cast <ITrainingProgramme>()) .OrderBy(m => m.Title) .ToList(); return(new GetTrainingProgrammesQueryResponse { TrainingProgrammes = programmes }); }