Exemplo n.º 1
0
        private List <Task <CivilFileDetailResponse> > CivilFileDetailTasks(List <string> fileIds)
        {
            var fileDetailTasks = new List <Task <CivilFileDetailResponse> >();

            foreach (var fileId in fileIds)
            {
                async Task <CivilFileDetailResponse> FileDetails() => await _filesClient.FilesCivilFileIdAsync(_requestAgencyIdentifierId, _requestPartId, fileId);

                fileDetailTasks.Add(_cache.GetOrAddAsync($"CivilFileDetail-{fileId}", FileDetails));
            }

            return(fileDetailTasks);
        }
        public async Task <RedactedCivilFileDetailResponse> FileIdAsync(string fileId)
        {
            async Task <CivilFileDetailResponse> FileDetails() => await _filesClient.FilesCivilFileIdAsync(_requestAgencyIdentifierId, _requestPartId, fileId);
            async Task <CivilFileContent> FileContent() => await _filesClient.FilesCivilFilecontentAsync(null, null, null, null, fileId);
            async Task <CivilFileAppearancesResponse> Appearances() => await PopulateDetailAppearancesAsync(FutureYN2.Y, HistoryYN2.Y, fileId);

            var fileDetailTask  = _cache.GetOrAddAsync($"CivilFileDetail-{fileId}", FileDetails);
            var fileContentTask = _cache.GetOrAddAsync($"CivilFileContent-{fileId}", FileContent);
            var appearancesTask = _cache.GetOrAddAsync($"CivilAppearancesFull-{fileId}", Appearances);

            var fileDetail  = await fileDetailTask;
            var appearances = await appearancesTask;
            var fileContent = await fileContentTask;

            if (fileDetail?.PhysicalFileId == null)
            {
                return(null);
            }

            var detail = _mapper.Map <RedactedCivilFileDetailResponse>(fileDetail);

            foreach (var document in PopulateDetailCsrsDocuments(fileDetail.Appearance))
            {
                detail.Document.Add(document);
            }

            detail = await PopulateBaseDetail(detail);

            detail.Appearances     = appearances;
            detail.FileCommentText = fileContent.CivilFile.First(cf => cf.PhysicalFileID == fileId).FileCommentText;
            detail.Party           = await PopulateDetailParties(detail.Party);

            detail.Document = await PopulateDetailDocuments(detail.Document);

            detail.HearingRestriction = await PopulateDetailHearingRestrictions(fileDetail.HearingRestriction);

            return(detail);
        }