Exemple #1
0
        public async Task <IActionResult> DeleteFile(Guid Id, int sequenceNo, Guid sectionId, string pageId, string questionId, string filename, string __redirectAction)
        {
            var section = await _qnaApiClient.GetSection(Id, sectionId);

            await _qnaApiClient.DeleteFile(Id, section.Id, pageId, questionId, filename);

            return(RedirectToAction("Page", new { Id, sequenceNo, section.SectionNo, pageId, __redirectAction }));
        }
Exemple #2
0
        public async Task <IActionResult> DownloadFiles(Guid applicationId, Guid sectionId)
        {
            var financialSection = await _qnaApiClient.GetSection(applicationId, sectionId);

            var application = await _applyApiClient.GetApplication(applicationId);

            if (financialSection != null)
            {
                using (var zipStream = new MemoryStream())
                {
                    using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
                    {
                        var pagesContainingQuestionsWithFileupload = financialSection.QnAData.Pages.Where(x => x.Questions.Any(y => y.Input.Type == "FileUpload")).ToList();
                        foreach (var uploadPage in pagesContainingQuestionsWithFileupload)
                        {
                            foreach (var uploadQuestion in uploadPage.Questions)
                            {
                                foreach (var answer in financialSection.QnAData.Pages.SelectMany(p => p.PageOfAnswers).SelectMany(a => a.Answers).Where(a => a.QuestionId == uploadQuestion.QuestionId))
                                {
                                    if (string.IsNullOrWhiteSpace(answer.ToString()))
                                    {
                                        continue;
                                    }

                                    var fileDownloadName = answer.Value;

                                    var downloadedFile = await _qnaApiClient.DownloadFile(applicationId, financialSection.Id, uploadPage.PageId, uploadQuestion.QuestionId, fileDownloadName);

                                    if (downloadedFile.IsSuccessStatusCode)
                                    {
                                        var destinationFilePath = Path.Combine(uploadPage.PageId, Path.GetFileName(fileDownloadName));
                                        var zipEntry            = zipArchive.CreateEntry(destinationFilePath);
                                        using (var entryStream = zipEntry.Open())
                                        {
                                            var fileStream = await downloadedFile.Content.ReadAsStreamAsync();

                                            fileStream.CopyTo(entryStream);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    zipStream.Position = 0;

                    return(File(zipStream.ToArray(), "application/zip", $"FinancialDocuments_{application.ApplyData.ApplyDetails.OrganisationName}.zip"));
                }
            }

            return(new NotFoundResult());
        }
        public async Task <IActionResult> Section(Guid applicationId, int sequenceNo, int sectionNo, BackViewModel backViewModel)
        {
            var application = await _applyApiClient.GetApplication(applicationId);

            var organisation = await _apiClient.GetOrganisation(application.OrganisationId);

            var applySequence = application.ApplyData.Sequences.Single(x => x.SequenceNo == sequenceNo);
            var applySection  = applySequence.Sections.Single(x => x.SectionNo == sectionNo);

            var sequence = await _qnaApiClient.GetSequence(application.ApplicationId, applySequence.SequenceId);

            var section = await _qnaApiClient.GetSection(application.ApplicationId, applySection.SectionId);

            var applicationData = await _qnaApiClient.GetApplicationDataDictionary(application.ApplicationId);

            var sectionVm = new SectionViewModel(application, organisation, section, applySection, applicationData, backViewModel.BackAction, backViewModel.BackController, backViewModel.BackOrganisationId);

            var activeApplicationStatuses = new List <string> {
                ApplicationStatus.Submitted, ApplicationStatus.Resubmitted
            };
            var activeSequenceStatuses = new List <string> {
                ApplicationSequenceStatus.Submitted, ApplicationSequenceStatus.Resubmitted
            };

            if (activeApplicationStatuses.Contains(application.ApplicationStatus) && activeSequenceStatuses.Contains(applySequence?.Status))
            {
                if (applySection.Status != ApplicationSectionStatus.Evaluated)
                {
                    await _applyApiClient.StartApplicationSectionReview(applicationId, sequence.SequenceNo, section.SectionNo, _contextAccessor.HttpContext.User.UserDisplayName());
                }

                return(View(nameof(Section), sectionVm));
            }
            else
            {
                return(View($"{nameof(Section)}_ReadOnly", sectionVm));
            }
        }