public async Task <string[]> Handle(GatherStandardsRequest request, CancellationToken cancellationToken)
        {
            var minimumHoursBetweenCollations = 23;
            var dateOfLastCollation           = await _standardRepository.GetDateOfLastStandardCollation();

            if (dateOfLastCollation == null || dateOfLastCollation.Value.AddHours(minimumHoursBetweenCollations) < DateTime.Now)
            {
                try
                {
                    _unitOfWork.Begin();

                    var ifaStandards = await _standardService.GetIfaStandards();

                    var approvedIfaStandards = ifaStandards.Where(p => p.LarsCode != 0).ToList();
                    _logger.LogInformation("Gathering approved Standard details from all sources in the handler");
                    var approvedStandardDetails = await _standardService.GatherAllApprovedStandardDetails(approvedIfaStandards);

                    _logger.LogInformation("Upserting gathered approved Standards");
                    var approvedResponse = await _standardRepository.UpsertApprovedStandards(approvedStandardDetails.ToList());

                    _logger.LogInformation("Processing of approved Standards upsert complete");

                    var nonApprovedIfaStandards = ifaStandards.Where(p => p.LarsCode == 0).ToList();
                    _logger.LogInformation("Gathering non-approved Standard details from all sources in the handler");
                    var nonApprovedStandardDetails = _standardService.GatherAllNonApprovedStandardDetails(nonApprovedIfaStandards);
                    _logger.LogInformation("Upserting gathered non-approved Standards");
                    var nonApprovedResponse = await _standardRepository.UpsertNonApprovedStandards(nonApprovedStandardDetails.ToList());

                    _logger.LogInformation("Processing of non-approved Standards upsert complete");

                    _unitOfWork.Commit();

                    return(new string[] { approvedResponse, nonApprovedResponse });
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Processing of Standards could not be completed");
                    _unitOfWork.Rollback();
                    throw;
                }
            }

            return(new string[] { $"Collation was last done on {dateOfLastCollation.Value}.  There is a minimum of {minimumHoursBetweenCollations} hours between collation runs" });
        }
        public async Task UpsertStandardNonApprovedCollations(IEnumerable <StandardDetailResponse> standards)
        {
            Func <StandardDetailResponse, StandardNonApprovedCollation> MapGetStandardsListItemToStandardNonApprovedCollation = source => new StandardNonApprovedCollation
            {
                ReferenceNumber = source.IfateReferenceNumber,
                Title           = source.Title,
                StandardData    = new StandardNonApprovedData
                {
                    Level            = source.Level,
                    Category         = source.Route,
                    IfaStatus        = source.Status,
                    IntegratedDegree = source.IntegratedDegree,
                    Duration         = source.TypicalDuration,
                    MaxFunding       = source.MaxFunding,
                    Trailblazer      = source.TrailBlazerContact,
                    OverviewOfRole   = source.OverviewOfRole,
                    StandardPageUrl  = source.StandardPageUrl
                }
            };

            var standardNonApprovedCollations = standards.Select(MapGetStandardsListItemToStandardNonApprovedCollation).ToList();

            await standardRepository.UpsertNonApprovedStandards(standardNonApprovedCollations);
        }