Esempio n. 1
0
        public async Task <IActionResult> ListPaymentsForLegalEntity(string accountId, string accountLegalEntityId, string sortOrder, string sortField)
        {
            if (string.IsNullOrWhiteSpace(sortOrder))
            {
                sortOrder = ApplicationsSortOrder.Ascending;
            }
            if (string.IsNullOrWhiteSpace(sortField))
            {
                sortField = ApplicationsSortField.ApprenticeName;
            }

            var getApplicationsResponse = await _apprenticeshipIncentiveService.GetList(accountId, accountLegalEntityId);

            var submittedApplications = getApplicationsResponse.ApprenticeApplications.AsQueryable();

            if (!submittedApplications.Any())
            {
                return(RedirectToAction("NoApplications", new { accountId, accountLegalEntityId }));
            }
            var legalEntity = await _legalEntitiesService.Get(accountId, accountLegalEntityId);

            //EI-896 - emergency fudge to stop the Paused/Withdrawn message being displayed for anyone with a payment.
            foreach (var apprenticeApplicationModel in submittedApplications)
            {
                if (apprenticeApplicationModel.FirstPaymentStatus != null)
                {
                    apprenticeApplicationModel.FirstPaymentStatus.InLearning = true;
                }

                if (apprenticeApplicationModel.SecondPaymentStatus != null)
                {
                    apprenticeApplicationModel.SecondPaymentStatus.InLearning = true;
                }
            }

            submittedApplications = SortApplications(sortOrder, sortField, submittedApplications);

            var model = new ViewApplicationsViewModel
            {
                AccountId                      = accountId,
                AccountLegalEntityId           = accountLegalEntityId,
                Applications                   = submittedApplications,
                SortField                      = sortField,
                ShowBankDetailsInReview        = getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.InProgress,
                ShowAddBankDetailsCalltoAction = getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.NotSupplied || getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.Rejected,
                AddBankDetailsLink             = CreateAddBankDetailsLink(accountId, getApplicationsResponse.FirstSubmittedApplicationId),
                OrganisationName               = legalEntity?.Name
            };

            model.SetSortOrder(sortField, sortOrder);

            return(View("ListPayments", model));
        }
Esempio n. 2
0
        public async Task <IActionResult> ListPaymentsForLegalEntity(string accountId, string accountLegalEntityId, string sortOrder, string sortField)
        {
            if (string.IsNullOrWhiteSpace(sortOrder))
            {
                sortOrder = ApplicationsSortOrder.Ascending;
            }
            if (string.IsNullOrWhiteSpace(sortField))
            {
                sortField = ApplicationsSortField.ApprenticeName;
            }

            var getApplicationsResponse = await _applicationService.GetList(accountId, accountLegalEntityId);

            var submittedApplications = getApplicationsResponse.ApprenticeApplications.AsQueryable();

            if (!submittedApplications.Any())
            {
                return(RedirectToAction("NoApplications", new { accountId, accountLegalEntityId }));
            }

            var viewAgreementLink = CreateViewAgreementLink(accountId);
            var legalEntity       = await _legalEntitiesService.Get(accountId, accountLegalEntityId);

            submittedApplications = submittedApplications.Sort(sortOrder, sortField);
            submittedApplications.ForEach(m =>
            {
                m.SetClawedBackStatus();
                m.SetInLearning();
                m.SetViewAgreementLink(viewAgreementLink);
            });

            var model = new ViewApplicationsViewModel
            {
                AccountId                      = accountId,
                AccountLegalEntityId           = accountLegalEntityId,
                Applications                   = submittedApplications,
                SortField                      = sortField,
                ShowBankDetailsInReview        = getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.InProgress,
                ShowAddBankDetailsCalltoAction = getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.NotSupplied || getApplicationsResponse.BankDetailsStatus == BankDetailsStatus.Rejected,
                AddBankDetailsLink             = CreateAddBankDetailsLink(accountId, getApplicationsResponse.FirstSubmittedApplicationId),
                ShowAcceptNewEmployerAgreement = getApplicationsResponse.ApprenticeApplications.Any(a => (a.FirstPaymentStatus != null && a.FirstPaymentStatus.RequiresNewEmployerAgreement) || (a.SecondPaymentStatus != null && a.SecondPaymentStatus.RequiresNewEmployerAgreement)),
                OrganisationName               = legalEntity?.Name,
                ViewAgreementLink              = viewAgreementLink,
                ShowCancelLink                 = getApplicationsResponse.ApprenticeApplications.Any(a => !a.IsWithdrawn),
                CancelLink                     = CreateCancelApprenticesLink(accountId, accountLegalEntityId)
            };

            model.SetSortOrder(sortField, sortOrder);

            return(View("ListPayments", model));
        }