private string GenerateApprenticeshipDQIMessages(ApprenticeshipDashboardCounts counts)
        {
            var messages = new List <string>();

            int totalAppCount = 0;

            if (counts.BulkUploadPendingCount.HasValue)
            {
                totalAppCount += counts.BulkUploadPendingCount.Value;
            }
            if (counts.BulkUploadReadyToGoLiveCount.HasValue)
            {
                totalAppCount += counts.BulkUploadReadyToGoLiveCount.Value;
            }

            if (counts.TotalErrors.HasValue && counts.TotalErrors.Value > 0)
            {
                return($"{totalAppCount} apprenticeship{(totalAppCount > 1 ? "s" : "")} uploaded in a file on {counts.FileUploadDate.Value:dd/MM/yyyy} {(totalAppCount > 1 ? "have" : "has")} {counts.TotalErrors} errors. " +
                       $"Fix these to publish all of your apprenticeship{(totalAppCount > 1 ? "s" : "")}.");
            }

            if (counts.BulkUploadReadyToGoLiveCount.HasValue && counts.BulkUploadReadyToGoLiveCount.Value > 0)
            {
                if (counts.BulkUploadPendingCount.HasValue && counts.BulkUploadPendingCount.Value == 0)
                {
                    return($"{totalAppCount} apprenticeship{(totalAppCount > 1 ? "s" : "")} uploaded in a file on {counts.FileUploadDate.Value:dd/MM/yyyy} {(totalAppCount > 1 ? "have" : "has")} no errors but are not listed on the Course directory because you have not published {(totalAppCount > 1 ? "them" : "it")}.");
                }
            }
            return(string.Empty);
        }
        public async Task <ApprenticeshipDashboardCounts> GetApprenticeshipDashboardCounts(int ukprn)
        {
            ApprenticeshipDashboardCounts results = null;

            var client = _cosmosDbHelper.GetClient();
            var docs   = _cosmosDbHelper.GetApprenticeshipByUKPRN(client, _settings.ApprenticeshipCollectionId, ukprn);

            if (docs.Any())
            {
                results = new ApprenticeshipDashboardCounts
                {
                    PublishedApprenticeshipCount = docs.Count(x => x.RecordStatus == RecordStatus.Live),
                    BulkUploadPendingCount       = docs.Count(x => x.RecordStatus == RecordStatus.BulkUploadPending),
                    BulkUploadReadyToGoLiveCount = docs.Count(x => x.RecordStatus == RecordStatus.BulkUploadReadyToGoLive),
                    BulkUploadTotalCount         = docs.Count(x => x.RecordStatus == RecordStatus.BulkUploadReadyToGoLive || x.RecordStatus == RecordStatus.BulkUploadPending),
                    TotalErrors    = docs.Where(x => x.RecordStatus == RecordStatus.BulkUploadPending).SelectMany(x => x.BulkUploadErrors).Count(),
                    FileUploadDate = docs.Select(x => x.CreatedDate.Date).SingleOrDefault(),
                };
            }

            return(results);
        }