public async Task <RoatpWithdrawApplicationViewModel> GetWithdrawApplicationViewModel(Guid applicationId, string userName)
        {
            RoatpWithdrawApplicationViewModel viewModel = null;

            var application = await _applyApiClient.GetApplication(applicationId);

            var contact = await _applyApiClient.GetContactDetails(applicationId);

            if (application != null && contact != null)
            {
                viewModel = new RoatpWithdrawApplicationViewModel
                {
                    ApplicationId              = application.ApplicationId,
                    ApplicationStatus          = application.ApplicationStatus,
                    Ukprn                      = application.ApplyData.ApplyDetails.UKPRN,
                    ApplyLegalName             = application.ApplyData.ApplyDetails.OrganisationName,
                    ApplicationRoute           = application.ApplyData.ApplyDetails.ProviderRouteName,
                    ApplicationReferenceNumber = application.ApplyData.ApplyDetails.ReferenceNumber,
                    ApplicationEmailAddress    = contact.Email,
                    ApplicationSubmittedOn     = application.ApplyData.ApplyDetails.ApplicationSubmittedOn
                };
            }

            return(viewModel);
        }
Beispiel #2
0
        public async Task <RoatpGatewayApplicationViewModel> GetOverviewViewModel(GetApplicationOverviewRequest request)
        {
            var application = await _applyApiClient.GetApplication(request.ApplicationId);

            if (application is null)
            {
                return(null);
            }

            var oversightDetails = await _applyApiClient.GetOversightDetails(request.ApplicationId);

            var contact = await _applyApiClient.GetContactDetails(request.ApplicationId);

            var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails)
            {
                ApplicationEmailAddress = contact?.Email,
                Sequences = GetCoreGatewayApplicationViewModel()
            };

            var savedStatuses = await _applyApiClient.GetGatewayPageAnswers(request.ApplicationId);

            if (savedStatuses != null && !savedStatuses.Any())
            {
                var providerRoute = application.ApplyData.ApplyDetails.ProviderRoute;
                await _sectionsNotRequiredService.SetupNotRequiredLinks(request.ApplicationId, request.UserName, viewmodel, providerRoute);
            }
            else
            {
                foreach (var currentStatus in savedStatuses ?? new List <GatewayPageAnswerSummary>())
                {
                    // Inject the statuses and comments into viewmodel
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Status  = currentStatus?.Status;
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Comment = currentStatus?.Comments;
                }
            }

            var sections = viewmodel.Sequences.SelectMany(seq => seq.Sections);

            viewmodel.IsClarificationsSelectedAndAllFieldsSet = IsAskForClarificationActive(sections);
            viewmodel.ReadyToConfirm = IsReadyToConfirm(sections);

            return(viewmodel);
        }