public IActionResult Review(int id)
        {
            var licenceId = Session.GetCurrentLicenceId();

            var dops = LicenceApplicationViewModelBuilder.Build <DirectorOrPartnerCollectionViewModel>(licenceId);

            // TODO: A better defence against URL hacking?
            if (dops.DirectorsOrPartners.None(a => a.Id == id))
            {
                return(RedirectToAction(FormSection.DirectorsOrPartners, 2));
            }

            var model = dops.DirectorsOrPartners.Single(a => a.Id == id);

            LicenceApplicationViewModelBuilder.BuildCountriesFor(model);

            Session.SetCurrentDopStatus(id, model.IsPreviousPrincipalAuthority.IsPreviousPrincipalAuthority ?? false);

            if ((model.IsPreviousPrincipalAuthority.IsPreviousPrincipalAuthority ?? false) && model.PrincipalAuthorityId.HasValue)
            {
                Session.SetCurrentPaStatus(model.PrincipalAuthorityId.Value, true);
            }

            return(View(GetLastViewPath(FormSection.DirectorOrPartner), model));
        }
        public IActionResult SubmitApplication()
        {
            var licenceId = Session.GetCurrentLicenceId();
            var model     = LicenceApplicationViewModelBuilder.Build(licenceId);

            LicenceApplicationViewModelBuilder.BuildCountriesFor(model.PrincipalAuthority);

            model.DirectorOrPartner.DirectorsOrPartners =
                model.DirectorOrPartner.DirectorsOrPartners.Select(LicenceApplicationViewModelBuilder
                                                                   .BuildCountriesFor);
            model.AlternativeBusinessRepresentatives.AlternativeBusinessRepresentatives =
                model.AlternativeBusinessRepresentatives.AlternativeBusinessRepresentatives.Select(
                    LicenceApplicationViewModelBuilder.BuildCountriesFor);

            model.Validate();

            return(View(model));
        }
示例#3
0
        public IActionResult Review(int id)
        {
            var licenceId = Session.GetCurrentLicenceId();

            var abrs =
                LicenceApplicationViewModelBuilder
                .Build <AlternativeBusinessRepresentativeCollectionViewModel, AlternativeBusinessRepresentative>(licenceId,
                                                                                                                 x => x.AlternativeBusinessRepresentatives);

            // TODO: A better defence against URL hacking?
            if (abrs.AlternativeBusinessRepresentatives.None(a => a.Id == id))
            {
                return(RedirectToAction(FormSection.AlternativeBusinessRepresentatives, 3));
            }

            Session.SetCurrentAbrId(id);

            var model = abrs.AlternativeBusinessRepresentatives.Single(a => a.Id == id);

            LicenceApplicationViewModelBuilder.BuildCountriesFor(model);

            return(View(GetLastViewPath(FormSection.AlternativeBusinessRepresentative), model));
        }