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(LicenceApplicationViewModel model) { var licenceId = Session.GetCurrentLicenceId(); if (!model.AgreedToTermsAndConditions) { ModelState.AddModelError("AgreedToTermsAndConditions", "You must agree to the terms and conditions in order to submit your application."); var dbModel = LicenceApplicationViewModelBuilder.Build(licenceId); model.OrganisationDetails = dbModel.OrganisationDetails; model.PrincipalAuthority = dbModel.PrincipalAuthority; model.AlternativeBusinessRepresentatives = dbModel.AlternativeBusinessRepresentatives; model.DirectorOrPartner = dbModel.DirectorOrPartner; model.NamedIndividuals = dbModel.NamedIndividuals; model.Organisation = dbModel.Organisation; return(View("SubmitApplication", model)); } model.NewLicenceStatus = new LicenceStatusViewModel { Id = ConstantService.ApplicationSubmittedOnlineStatusId }; LicenceApplicationPostDataHandler.Update(licenceId, model); return(RedirectToAction("Portal")); }
public IActionResult TaskList() { Session.SetCurrentUserIsAdmin(false); Session.ClearCurrentPaStatus(); Session.ClearCurrentAbrId(); Session.ClearCurrentDopStatus(); var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build <LicenceApplicationViewModel>(licenceId); if (licenceId == 0) { Session.SetCurrentLicenceId(LicenceApplicationPostDataHandler.Insert(model)); } //TODO: It's feasible we could access this page with no licenceId where the model will be null //TODO: how should we handle this model.Declaration?.Validate(); model.OrganisationDetails?.Validate(); model.PrincipalAuthority?.Validate(); model.AlternativeBusinessRepresentatives?.Validate(); model.DirectorOrPartner?.Validate(); model.NamedIndividuals?.Validate(); model.Organisation?.Validate(); return(View(model)); }
private DirectorOrPartnerViewModel SetupGetPart(int id) { var licenceId = Session.GetCurrentLicenceId(); var dopId = Session.GetCurrentDopId(); var model = LicenceApplicationViewModelBuilder.Build <DirectorOrPartnerViewModel, DirectorOrPartner>( licenceId, l => l.DirectorOrPartners.SingleOrDefault(d => d.Id == dopId)); if (model.Id.HasValue) { Session.SetCurrentDopStatus(model.Id.Value, model.IsPreviousPrincipalAuthority.IsPreviousPrincipalAuthority ?? false); } if (model.PrincipalAuthorityId.HasValue) { Session.SetCurrentPaStatus(model.PrincipalAuthorityId.Value, model.IsPreviousPrincipalAuthority.IsPreviousPrincipalAuthority ?? false); } if (ViewData["IsSubmitted"] == null) { var currentStatus = LicenceStatusViewModelBuilder.BuildLatestStatus(licenceId); ViewData["IsSubmitted"] = currentStatus.Id == ConstantService.ApplicationSubmittedOnlineStatusId; } Session.SetLoadedPage(id); return(model); }
private AlternativeBusinessRepresentativeViewModel SetupGetPart(int id) { var licenceId = Session.GetCurrentLicenceId(); var abrId = Session.GetCurrentAbrId(); var model = LicenceApplicationViewModelBuilder .Build <AlternativeBusinessRepresentativeViewModel, AlternativeBusinessRepresentative>(licenceId, x => x.AlternativeBusinessRepresentatives.FirstOrDefault(a => a.Id == abrId)) ?? new AlternativeBusinessRepresentativeViewModel(); if (model.Id.HasValue) { Session.SetCurrentAbrId(model.Id.Value); } if (ViewData["IsSubmitted"] == null) { var currentStatus = LicenceStatusViewModelBuilder.BuildLatestStatus(licenceId); ViewData["IsSubmitted"] = currentStatus.Id == ConstantService.ApplicationSubmittedOnlineStatusId; } Session.SetLoadedPage(id); return(model); }
public IActionResult AddPreviousTradingName(string section, int id) { var model = LicenceApplicationViewModelBuilder.Build <PreviousTradingNameViewModel, PreviousTradingName>( Session.GetCurrentLicenceId(), l => l.PreviousTradingNames.SingleOrDefault(p => p.Id == id)) ?? new PreviousTradingNameViewModel(); return(View("SecurityQuestions/PreviousTradingName", model)); }
public IActionResult Part(int id, bool?back = false) { var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build <OrganisationViewModel>(licenceId); return(back.HasValue && back.Value ? GetPreviousView(id, FormSection.Organisation, model) : GetNextView(id, FormSection.Organisation, model)); }
private IActionResult OrganisationDetailsGet(string actionName, bool?back = false) { Session.SetLoadedPage(actionName); var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build <OrganisationDetailsViewModel>(licenceId); return(back.HasValue && back.Value ? GetPreviousView(FormSection.OrganisationDetails, actionName, model) : GetNextView(FormSection.OrganisationDetails, actionName, model)); }
public IActionResult Part(int id, bool?back) { var licenceId = Session.GetCurrentLicenceId(); var namedIndividualId = Session.GetCurrentNamedIndividualId(); var model = LicenceApplicationViewModelBuilder .Build <NamedJobTitleViewModel, NamedJobTitle>(licenceId, x => x.NamedJobTitles.FirstOrDefault(y => y.Id == namedIndividualId)); return(back.HasValue && back.Value ? GetPreviousView(id, FormSection.JobTitle, model) : GetNextView(id, FormSection.JobTitle, model)); }
public IActionResult Part(int id, bool?back = false) { var licenceId = Session.GetCurrentLicenceId(); Session.ClearCurrentNamedIndividualId(); var model = LicenceApplicationViewModelBuilder.Build <NamedIndividualCollectionViewModel>(licenceId); return(back.HasValue && back.Value ? GetPreviousView(id, FormSection.NamedIndividuals, model) : GetNextView(id, FormSection.NamedIndividuals, model)); }
public IActionResult Part(int id, bool?back) { Session.ClearCurrentDopStatus(); Session.ClearCurrentPaStatus(); var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build <DirectorOrPartnerCollectionViewModel>(licenceId); return(back.HasValue && back.Value ? GetPreviousView(id, FormSection.DirectorsOrPartners, model) : GetNextView(id, FormSection.DirectorsOrPartners, model)); }
public IActionResult Part(int id, bool?back) { Session.ClearCurrentAbrId(); var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder .Build <AlternativeBusinessRepresentativeCollectionViewModel>(licenceId); return(back.HasValue && back.Value ? GetPreviousView(id, FormSection.AlternativeBusinessRepresentatives, model) : GetNextView(id, FormSection.AlternativeBusinessRepresentatives, 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)); }
public IActionResult Portal() { var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build(licenceId); ViewData["IsSubmitted"] = false; model.NewLicenceStatus = LicenceStatusViewModelBuilder.BuildLatestStatus(licenceId); if (model.NewLicenceStatus.Id == ConstantService.ApplicationSubmittedOnlineStatusId || model.NewLicenceStatus.Id == ConstantService.ApplicationSubmittedByPhoneId) { ViewData["IsSubmitted"] = true; } return(View(nameof(Portal), model)); }
private PrincipalAuthorityViewModel SetupGetPart(int id) { var licenceId = Session.GetCurrentLicenceId(); var model = LicenceApplicationViewModelBuilder.Build <PrincipalAuthorityViewModel, PrincipalAuthority>(licenceId, x => x.PrincipalAuthorities.FirstOrDefault()); if (model.Id.HasValue) { Session.SetCurrentPaStatus(model.Id.Value, model.IsDirector.IsDirector ?? false); } if (model.DirectorOrPartnerId.HasValue) { Session.SetCurrentDopStatus(model.DirectorOrPartnerId.Value, model.IsDirector.IsDirector ?? false); } Session.SetLoadedPage(id); return(model); }
public IActionResult ReviewPrincipalAuthorityRestraintOrders(RestraintOrdersViewModel model) { Session.SetSubmittedPage(FormSection.PrincipalAuthority, 20); var licenceId = Session.GetCurrentLicenceId(); var parent = LicenceApplicationViewModelBuilder.Build <PrincipalAuthorityViewModel, PrincipalAuthority>(licenceId, l => l.PrincipalAuthorities.SingleOrDefault(p => p.Id == Session.GetCurrentPaId())); model = parent.RestraintOrdersViewModel; if ((model.HasRestraintOrders ?? false) && !model.RestraintOrders.Any()) { ModelState.AddModelError(nameof(model.RestraintOrders), "Please enter details of the restraint or confiscation orders or civil recoveries that you have been the subject of."); ViewData.Add("doOverride", true); return(View(GetViewPath(FormSection.PrincipalAuthority, 20), model)); } return(ValidateParentAndRedirect(parent, FormSection.PrincipalAuthority, 21)); }
public IActionResult ReviewDirectorOrPartnerUnspentConvictions(UnspentConvictionsViewModel model) { Session.SetSubmittedPage(FormSection.DirectorOrPartner, 22); var licenceId = Session.GetCurrentLicenceId(); var parent = LicenceApplicationViewModelBuilder.Build <DirectorOrPartnerViewModel, DirectorOrPartner>(licenceId, l => l.DirectorOrPartners.Single(p => p.Id == Session.GetCurrentDopId())); model = parent.UnspentConvictionsViewModel; if ((model.HasUnspentConvictions ?? false) && !model.UnspentConvictions.Any()) { ModelState.AddModelError(nameof(model.UnspentConvictions), "Please enter details of the unspent criminal convictions, or alternative sanctions or penalties for proven offences you have."); ViewData.Add("doOverride", true); return(View(GetViewPath(FormSection.DirectorOrPartner, 22), model)); } return(ValidateParentAndRedirect(parent, FormSection.DirectorOrPartner, 23)); }
public IActionResult ReviewPrincipalAuthorityOffencesAwaitingTrial(OffencesAwaitingTrialViewModel model) { Session.SetSubmittedPage(FormSection.PrincipalAuthority, 24); var licenceId = Session.GetCurrentLicenceId(); var parent = LicenceApplicationViewModelBuilder.Build <PrincipalAuthorityViewModel, PrincipalAuthority>(licenceId, l => l.PrincipalAuthorities.SingleOrDefault(p => p.Id == Session.GetCurrentPaId())); model = parent.OffencesAwaitingTrialViewModel; if ((model.HasOffencesAwaitingTrial ?? false) && !model.OffencesAwaitingTrial.Any()) { ModelState.AddModelError(nameof(model.OffencesAwaitingTrial), "Please enter details of the unspent criminal convictions, or alternative sanctions or penalties for proven offences you have."); ViewData.Add("doOverride", true); return(View(GetViewPath(FormSection.PrincipalAuthority, 24), model)); } return(ValidateParentAndRedirect(parent, FormSection.PrincipalAuthority, 25)); }
public IActionResult ReviewAlternativeBusinessRepresentativeRestraintOrders(RestraintOrdersViewModel model) { Session.SetSubmittedPage(FormSection.AlternativeBusinessRepresentative, 17); var licenceId = Session.GetCurrentLicenceId(); var parent = LicenceApplicationViewModelBuilder.Build <AlternativeBusinessRepresentativeViewModel, AlternativeBusinessRepresentative>(licenceId, l => l.AlternativeBusinessRepresentatives.Single(p => p.Id == Session.GetCurrentAbrId())); model = parent.RestraintOrdersViewModel; if ((model.HasRestraintOrders ?? false) && !model.RestraintOrders.Any()) { ModelState.AddModelError(nameof(model.RestraintOrders), "Please enter details of the restraint or confiscation orders or civil recoveries that you have been the subject of."); ViewData.Add("doOverride", true); return(View(GetViewPath(FormSection.AlternativeBusinessRepresentative, 17), model)); } return(ValidateParentAndRedirect(parent, FormSection.AlternativeBusinessRepresentative, 18)); }
public IActionResult AddConviction(FormSection section, int id) { Func <Licence, Conviction> selector; switch (section) { case FormSection.PrincipalAuthority: selector = l => l.PrincipalAuthorities.Single(pa => pa.Id == Session.GetCurrentPaId()).UnspentConvictions .SingleOrDefault(uc => uc.Id == id); break; case FormSection.AlternativeBusinessRepresentative: selector = l => l.AlternativeBusinessRepresentatives.Single(abr => abr.Id == Session.GetCurrentAbrId()).UnspentConvictions .SingleOrDefault(uc => uc.Id == id); break; case FormSection.DirectorOrPartner: selector = l => l.DirectorOrPartners.Single(dop => dop.Id == Session.GetCurrentDopId()).UnspentConvictions .SingleOrDefault(uc => uc.Id == id); break; case FormSection.NamedIndividual: selector = l => l.NamedIndividuals.Single(ni => ni.Id == Session.GetCurrentNamedIndividualId()).UnspentConvictions .SingleOrDefault(uc => uc.Id == id); break; default: selector = l => null; break; } var model = LicenceApplicationViewModelBuilder.Build <UnspentConvictionViewModel, Conviction>( Session.GetCurrentLicenceId(), selector) ?? new UnspentConvictionViewModel(); return(View("SecurityQuestions/UnspentConviction", model)); }
public async Task <IActionResult> ViewApplication() { var user = await userManager.GetUserAsync(HttpContext.User); var model = LicenceApplicationViewModelBuilder.BuildLicencesForUser(user.Id).FirstOrDefault(); var licenceId = Session.GetCurrentLicenceId(); if (model != null) { model.NewLicenceStatus = LicenceStatusViewModelBuilder.BuildLatestStatus(model.Id); ViewData["IsSubmitted"] = model.NewLicenceStatus.Id == ConstantService.ApplicationSubmittedOnlineStatusId; return(View(model)); } else { return(RedirectToAction(nameof(TaskList))); } }
public IActionResult Review(int id) { var licenceId = Session.GetCurrentLicenceId(); var models = LicenceApplicationViewModelBuilder .Build <NamedIndividualCollectionViewModel, NamedJobTitle>(licenceId, x => x.NamedJobTitles); // TODO: A better defence against URL hacking? if (models.NamedJobTitles.All(ni => ni.Id != id)) { return(RedirectToAction(FormSection.NamedIndividuals, 3)); } Session.SetCurrentNamedIndividualId(id); var model = models.NamedJobTitles.Single(a => a.Id == id); return(View(GetLastViewPath(FormSection.JobTitle), model)); }
public IActionResult Resume(ResumeApplicationViewModel model) { if (ModelState.IsValid) { //TODO: We need a smaller / quicker check for existance here var licence = LicenceApplicationViewModelBuilder.Build(model.ApplicationId); if (licence != null) { Session.SetCurrentLicenceId(licence.Id); Session.SetString("ApplicationId", model.ApplicationId); return(RedirectToAction("TaskList")); } ModelState.AddModelError("ApplicationNotFound", $"We were unable to find your application with the ID: {model.ApplicationId}."); ViewData.Add("doOverride", true); } return(View(model)); }
private NamedIndividualViewModel SetupGetPart(int id) { var licenceId = Session.GetCurrentLicenceId(); var namedIndividualId = Session.GetCurrentNamedIndividualId(); var model = LicenceApplicationViewModelBuilder .Build <NamedIndividualViewModel, NamedIndividual>(licenceId, x => x.NamedIndividuals.FirstOrDefault(y => y.Id == namedIndividualId)); if (model.Id.HasValue) { Session.SetCurrentNamedIndividualId(model.Id.Value); } if (ViewData["IsSubmitted"] == null) { var currentStatus = LicenceStatusViewModelBuilder.BuildLatestStatus(licenceId); ViewData["IsSubmitted"] = currentStatus.Id == ConstantService.ApplicationSubmittedOnlineStatusId; } Session.SetLoadedPage(id); return(model); }
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)); }
public IActionResult SaveIsDirector(IsDirectorViewModel model) { Session.SetSubmittedPage(FormSection.PrincipalAuthority, 2); if (!ModelState.IsValid || !model.IsDirector.HasValue) { return(View(GetViewPath(FormSection.PrincipalAuthority, 2), model)); } var paId = LicenceApplicationPostDataHandler.Update(Session.GetCurrentLicenceId(), x => x.PrincipalAuthorities, model, Session.GetCurrentPaId()); Session.SetCurrentPaStatus(paId, model.IsDirector.Value); if (model.IsDirector.Value) { var licenceModel = LicenceApplicationViewModelBuilder.Build(Session.GetCurrentLicenceId()); var existingDirectorOrPartnerId = licenceModel.PrincipalAuthority.DirectorOrPartnerId ?? 0; var dopId = LicenceApplicationPostDataHandler.Update(Session.GetCurrentLicenceId(), l => l.DirectorOrPartners, model, existingDirectorOrPartnerId); Session.SetCurrentDopStatus(dopId, true); LicenceApplicationPostDataHandler.UpsertDirectorOrPartnerAndLinkToPrincipalAuthority( Session.GetCurrentLicenceId(), paId, dopId, model); return(RedirectToAction(FormSection.PrincipalAuthority, 4)); } LicenceApplicationPostDataHandler.UnlinkDirectorOrPartnerFromPrincipalAuthority(Session.GetCurrentPaId()); return(CheckParentValidityAndRedirect(FormSection.PrincipalAuthority, 2)); }