Exemplo n.º 1
0
        public async Task <IActionResult> ChangeApplicationProviderRoute(Guid applicationId)
        {
            var model = new SelectApplicationRouteViewModel {
                ApplicationId = applicationId
            };

            PopulateGetHelpWithQuestion(model, "ApplicationRoute");
            model.ApplicationRoutes = await GetApplicationRoutesForOrganisation(applicationId);

            var applicationRoute = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.ProviderRoute);

            model.ApplicationRouteId = Convert.ToInt32(applicationRoute.Value);

            return(View("~/Views/Roatp/SelectApplicationRoute.cshtml", model));
        }
        public async Task <string> GetTokenisedValue(Guid applicationId, string tokenisedValue)
        {
            if (string.IsNullOrEmpty(tokenisedValue))
            {
                return(string.Empty);
            }

            int maxCounter   = 5;
            int startCounter = 0;

            while (ContainsTokens(tokenisedValue) && startCounter < maxCounter)
            {
                var questionTagName = GetTokenIdentifier(tokenisedValue);

                var stringToReplace = $"{StartTokenPattern}{questionTagName}{EndTokenPattern}";

                var questionValue = await _qnaApiClient.GetAnswerByTag(applicationId, questionTagName);

                if (questionValue != null)
                {
                    var tokenReplacementValue = tokenisedValue.Replace(stringToReplace, WebUtility.HtmlEncode(questionValue.Value));
                    tokenisedValue = tokenReplacementValue;
                }

                startCounter++;
            }

            return(tokenisedValue);
        }
        public async Task <IActionResult> StartPage(Guid applicationId)
        {
            var peopleData = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.AddManagementHierarchy);

            if (peopleData?.Value != null)
            {
                return(await ConfirmManagementHierarchy(applicationId));
            }

            return(AddManagementHierarchy(applicationId));
        }
Exemplo n.º 4
0
        public async Task <TabularData> GetTabularDataAnswer(Guid applicationId, string questionTag)
        {
            var answer = await _apiClient.GetAnswerByTag(applicationId, questionTag);

            if (answer == null || answer.Value == null)
            {
                return(null);
            }

            var tabularData = JsonConvert.DeserializeObject <TabularData>(answer.Value);

            return(tabularData);
        }
Exemplo n.º 5
0
        public async Task <int> GetApplicationProviderTypeId(Guid applicationId)
        {
            var providerTypeId = 0;

            var providerTypeAnswer =
                await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.ProviderRoute);

            if (providerTypeAnswer != null && !String.IsNullOrWhiteSpace(providerTypeAnswer.Value))
            {
                int.TryParse(providerTypeAnswer.Value, out providerTypeId);
            }

            return(providerTypeId == 0 ? 1 : providerTypeId);
        }
        public async Task <TaskListViewModel> GetTaskListViewModel(Guid applicationId, Guid userId)
        {
            var organisationDetailsTask            = _apiClient.GetOrganisationByUserId(userId);
            var providerRouteTask                  = _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.ProviderRoute);
            var organisationVerificationStatusTask = _organisationVerificationService.GetOrganisationVerificationStatus(applicationId);
            var refreshNotRequiredOverridesTask    = _notRequiredOverridesService.RefreshNotRequiredOverridesAsync(applicationId);
            var sequencesTask = _roatpTaskListWorkflowService.GetApplicationSequences(applicationId);

            await Task.WhenAll(organisationDetailsTask, providerRouteTask, organisationVerificationStatusTask, refreshNotRequiredOverridesTask, sequencesTask);

            var organisationDetails            = await organisationDetailsTask;
            var providerRoute                  = await providerRouteTask;
            var organisationVerificationStatus = await organisationVerificationStatusTask;
            var sequences = (await sequencesTask).ToList();

            var yourOrganisationSequenceCompleted = await IsYourOrganisationSequenceCompleted(applicationId, sequences, organisationVerificationStatus);

            var applicationSequencesCompleted = await ApplicationSequencesCompleted(applicationId, sequences, organisationVerificationStatus);

            var lastFinishSectionCompleted = await _roatpTaskListWorkflowService.PreviousSectionCompleted(applicationId, RoatpWorkflowSequenceIds.Finish, RoatpWorkflowSectionIds.Finish.SubmitApplication, sequences, organisationVerificationStatus);

            var result = new TaskListViewModel
            {
                ApplicationId               = applicationId,
                ApplicationRouteId          = providerRoute.Value,
                ApplicationSummaryViewModel = new ApplicationSummaryViewModel
                {
                    ApplicationId      = applicationId,
                    UKPRN              = organisationDetails.OrganisationUkprn?.ToString(),
                    OrganisationName   = organisationDetails.Name,
                    TradingName        = organisationDetails.OrganisationDetails?.TradingName,
                    ApplicationRouteId = providerRoute.Value,
                },
                AllowSubmission = applicationSequencesCompleted && lastFinishSectionCompleted
            };

            foreach (var sequence in sequences)
            {
                var sequenceVm = new TaskListViewModel.Sequence
                {
                    Id          = sequence.SequenceId,
                    Description = sequence.Description
                };

                result.Sequences.Add(sequenceVm);

                foreach (var section in sequence.Sections.OrderBy(x => x.SectionId))
                {
                    sequenceVm.Sections.Add(new TaskListViewModel.Section
                    {
                        Id            = section.SectionId,
                        Title         = section.Title,
                        IsNotRequired = await _roatpTaskListWorkflowService.SectionNotRequired(applicationId, sequence.SequenceId, section.SectionId),
                        Status        = sequence.SequenceId == RoatpWorkflowSequenceIds.Finish
                                ? await _roatpTaskListWorkflowService.FinishSectionStatus(applicationId, section.SectionId, sequences, applicationSequencesCompleted)
                                : await _roatpTaskListWorkflowService.SectionStatusAsync(applicationId, sequence.SequenceId, section.SectionId, sequences, organisationVerificationStatus),
                        IsLocked = await IsSectionLocked(applicationId, sequence.SequenceId, section.SectionId, sequences, organisationVerificationStatus, yourOrganisationSequenceCompleted, applicationSequencesCompleted)
                    });
                }
            }

            return(result);
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Index(Guid?applicationId, int sequenceId, int sectionId, string pageId, string title, string getHelp, string controller, string action)
        {
            var getHelpQuery    = new GetHelpWithQuestion();
            var errorMessageKey = string.Format(GetHelpErrorMessageKey, pageId);

            if (string.IsNullOrWhiteSpace(getHelp))
            {
                _sessionService.Set(errorMessageKey, MinLengthErrorMessage);
                var questionKey = string.Format(GetHelpQuestionKey, pageId);
                _sessionService.Set(questionKey, string.Empty);
                return(RedirectToAction(action, controller, new { applicationId, sequenceId, sectionId, pageId }));
            }

            if (getHelp.Length > GetHelpTextMaxLength)
            {
                _sessionService.Set(errorMessageKey, MaxLengthErrorMessage);
                var questionKey = string.Format(GetHelpQuestionKey, pageId);
                _sessionService.Set(questionKey, getHelp);
                return(RedirectToAction(action, controller, new { applicationId, sequenceId, sectionId, pageId }));
            }

            if (applicationId.HasValue && applicationId.Value != Guid.Empty)
            {
                if (sequenceId > 0 && sectionId > 0)
                {
                    var page = await _qnaApiClient.GetPageBySectionNo(applicationId.Value, sequenceId, sectionId, pageId);

                    if (page == null || string.IsNullOrEmpty(page.Title))
                    {
                        getHelpQuery.PageTitle = title;
                    }
                    else
                    {
                        getHelpQuery.PageTitle = page.Title;
                    }

                    var sequenceConfig = _taskListConfiguration.FirstOrDefault(x => x.Id == sequenceId);
                    if (sequenceConfig != null)
                    {
                        getHelpQuery.ApplicationSequence = sequenceConfig.Title;
                    }

                    var currentSection = await _qnaApiClient.GetSectionBySectionNo(applicationId.Value, sequenceId, sectionId);

                    if (currentSection != null)
                    {
                        getHelpQuery.ApplicationSection = currentSection.Title;
                    }
                }
                else
                {
                    getHelpQuery.PageTitle           = title;
                    getHelpQuery.ApplicationSequence = "Not available";
                    getHelpQuery.ApplicationSection  = "Not available";
                }

                var organisationName = await _qnaApiClient.GetAnswerByTag(applicationId.Value, RoatpWorkflowQuestionTags.UkrlpLegalName);

                if (organisationName != null && !string.IsNullOrWhiteSpace(organisationName.Value))
                {
                    getHelpQuery.OrganisationName = organisationName.Value;
                }
                else
                {
                    getHelpQuery.OrganisationName = "Not available";
                }

                var organisationUKPRN = await _qnaApiClient.GetAnswerByTag(applicationId.Value, RoatpWorkflowQuestionTags.UKPRN);

                if (organisationUKPRN != null && !string.IsNullOrWhiteSpace(organisationUKPRN.Value))
                {
                    getHelpQuery.UKPRN = organisationUKPRN.Value;
                }
                else
                {
                    getHelpQuery.UKPRN = "Not available";
                }
            }
            else
            {
                // in preamble so we don't have an application set up yet
                var applicationDetails = _sessionService.Get <ApplicationDetails>(ApplicationDetailsKey);
                getHelpQuery.PageTitle           = title;
                getHelpQuery.ApplicationSequence = "Preamble";
                getHelpQuery.ApplicationSection  = "Preamble";
                var ukprn = applicationDetails?.UKPRN.ToString();
                if (string.IsNullOrWhiteSpace(ukprn))
                {
                    ukprn = "Not available";
                }
                getHelpQuery.UKPRN = ukprn;
                var organisationName = applicationDetails?.UkrlpLookupDetails?.ProviderName;
                if (string.IsNullOrWhiteSpace(organisationName))
                {
                    organisationName = "Not available";
                }
                getHelpQuery.OrganisationName = organisationName;
            }

            getHelpQuery.GetHelpQuery = getHelp;

            var userDetails = await _usersApiClient.GetUserBySignInId(User.GetSignInId());

            getHelpQuery.EmailAddress      = userDetails.Email;
            getHelpQuery.ApplicantFullName = $"{userDetails.GivenNames} {userDetails.FamilyName}";

            await _emailService.SendGetHelpWithQuestionEmail(getHelpQuery);

            var sessionKey = string.Format(GetHelpSubmittedForPageKey, pageId);

            _sessionService.Set(sessionKey, true);
            _sessionService.Set(errorMessageKey, string.Empty);

            return(RedirectToAction(action, controller, new { applicationId, sequenceId, sectionId, pageId }));
        }
        public async Task <IActionResult> DirectorsPscsConfirmed(Guid applicationId)
        {
            var companiesHouseDirectorsAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.CompaniesHouseDirectors, RoatpYourOrganisationQuestionIdConstants.CompaniesHouseDirectors);

            var companiesHousePscsAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.CompaniesHousePscs, RoatpYourOrganisationQuestionIdConstants.CompaniesHousePSCs);

            var answers = new List <Answer>()
            {
                companiesHouseDirectorsAnswer,
                companiesHousePscsAnswer,
                new Answer
                {
                    QuestionId = RoatpYourOrganisationQuestionIdConstants.CompaniesHouseDetailsConfirmed,
                    Value      = "Y"
                }
            };

            var updateResult = await _qnaApiClient.UpdatePageAnswers(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.CompaniesHouseStartPage, answers);

            if (!updateResult.ValidationPassed)
            {
                return(RedirectToAction("ConfirmDirectorsPscs", new { applicationId }));
            }
            else
            {
                var verificationCharityAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.UkrlpVerificationCharity);

                if (verificationCharityAnswer.Value == "TRUE")
                {
                    return(RedirectToAction("ConfirmTrustees", new { applicationId }));
                }

                return(RedirectToAction("TaskList", "RoatpApplication", new { applicationId }, "Sequence_1"));
            }
        }
Exemplo n.º 9
0
        public async Task <IActionResult> StartPage(Guid applicationId)
        {
            var verificationCompanyAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.UkrlpVerificationCompany);

            var companiesHouseManualEntryAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.ManualEntryRequiredCompaniesHouse);

            if ((verificationCompanyAnswer.Value == "TRUE") &&
                (companiesHouseManualEntryAnswer.Value != "TRUE"))
            {
                return(await ConfirmDirectorsPscs(applicationId));
            }
            var verificationCharityAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.UkrlpVerificationCharity);

            var charityCommissionManualEntryAnswer = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.ManualEntryRequiredCharityCommission);

            if ((verificationCharityAnswer.Value == "TRUE") &&
                (charityCommissionManualEntryAnswer.Value != "TRUE"))
            {
                return(await ConfirmTrusteesNoDob(applicationId));
            }

            var verificationPartnership = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.UkrlpVerificationSoleTraderPartnership);

            if (verificationPartnership.Value == "TRUE")
            {
                return(await SoleTraderOrPartnership(applicationId));
            }

            var peopleData = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.AddPeopleInControl);

            if (peopleData != null && peopleData.Value != null)
            {
                return(await ConfirmPeopleInControl(applicationId));
            }

            return(await AddPeopleInControl(applicationId));
        }