From 689c1e5b20a8f03718024fa06d8f4d71364fbd71 Mon Sep 17 00:00:00 2001 From: "william.byrne@finance-ni.gov.uk" Date: Tue, 2 Nov 2021 15:58:22 +0000 Subject: [PATCH] Adding caveat solicitor question. --- Controllers/CaveatController.cs | 102 ++++++++++++++++++++++++++++ Helpers/HelperMethods.cs | 68 +++++++++++++++++++ Views/Caveat/Question.cshtml | 38 +++++++++++ Views/Home/Index.cshtml | 3 + wwwroot/config/CaveatQuestions.json | 12 ++++ 5 files changed, 223 insertions(+) create mode 100644 Controllers/CaveatController.cs create mode 100644 Views/Caveat/Question.cshtml create mode 100644 wwwroot/config/CaveatQuestions.json diff --git a/Controllers/CaveatController.cs b/Controllers/CaveatController.cs new file mode 100644 index 0000000..125c905 --- /dev/null +++ b/Controllers/CaveatController.cs @@ -0,0 +1,102 @@ +using eligibility_checker.Models; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace eligibility_checker.Controllers +{ + public class CaveatController : Controller + { + private readonly IWebHostEnvironment _env; + + public CaveatController(IWebHostEnvironment env) + { + _env = env; + } + + [HttpGet] + public IActionResult Index(string page) + { + ViewBag.ServiceName = "Apply for Caveat"; + + if (string.IsNullOrWhiteSpace(page)) + { + // Start + var model = GetPage("start"); + var viewModel = new PageViewModel(model); + return View(model.Template, viewModel); + + } + else + { + if (page == "solicitor-redirect") + { + return Redirect(Helpers.HelperMethods.GetSolicitorLinkCaveat(_env.EnvironmentName)); + } + + if (page == "citizen-redirect") + { + return Redirect(Helpers.HelperMethods.GetCitizenLinkCaveat(_env.EnvironmentName)); + } + + var model = GetPage(page); + var viewModel = new PageViewModel(model); + + return View(model.Template, viewModel); + } + } + + [HttpPost] + [ValidateAntiForgeryToken] + public IActionResult Index(bool answer, string page) + { + ViewBag.ServiceName = "Apply for Caveat"; + + var source = GetPage(page); + if (answer) + { + return RedirectToAction("Index", new { page = source.OnYes }); + } + else + { + return RedirectToAction("Index", new { page = source.OnNo }); + } + } + + [HttpGet] + public ActionResult Accessibility() + { + ViewBag.ServiceName = "Check eligibility"; + + var model = GetPage("Accessibility"); + model.Header = "Accessibility"; + var viewModel = new PageViewModel(model); + return View(viewModel); + } + + private PageModel GetPage(string page) + { + var list = GetPages(); + return list.First(item => item.Page.ToLower() == page.ToLower()); + } + + private List GetPages() + { + var folderDetails = Path.Combine(Directory.GetCurrentDirectory(), $"wwwroot//{"config//CaveatQuestions.json"}"); + var json = System.IO.File.ReadAllText(folderDetails); + var list = JsonConvert.DeserializeObject>(json); + return list; + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + ViewBag.ServiceName = "Apply for Caveat"; + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} diff --git a/Helpers/HelperMethods.cs b/Helpers/HelperMethods.cs index 3cb92e3..0741341 100644 --- a/Helpers/HelperMethods.cs +++ b/Helpers/HelperMethods.cs @@ -39,6 +39,40 @@ public static string GetCitizenLink(string environment) return urlToReturn; } + /// + /// This determines what env the app is in and provides the citizen link to the app for caveat. + /// + /// + /// + public static string GetCitizenLinkCaveat(string environment) + { + string urlToReturn = string.Empty; + + switch (environment) + { + case "Development": + urlToReturn = "https://nicts-probate-sandbox.london.cloudapps.digital/Caveat"; + break; + + case "Sandbox": + urlToReturn = "https://nicts-probate-sandbox.london.cloudapps.digital/Caveat"; + break; + + case "Staging": + urlToReturn = "https://nicts-probate-staging.london.cloudapps.digital/Caveat"; + break; + + case "Production": + urlToReturn = "https://apply-for-probate.nidirect.gov.uk/Caveat"; + break; + + default: + break; + } + + return urlToReturn; + } + /// /// This determines what env the app is in and provides the solicitor link to the app. /// @@ -72,5 +106,39 @@ public static string GetSolicitorLink(string environment) return urlToReturn; } + + /// + /// This determines what env the app is in and provides the solicitor link to the app for caveat. + /// + /// + /// + public static string GetSolicitorLinkCaveat(string environment) + { + string urlToReturn = string.Empty; + + switch (environment) + { + case "Development": + urlToReturn = "https://nicts-probate-solicitor-sandbox.london.cloudapps.digital/Caveat"; + break; + + case "Sandbox": + urlToReturn = "https://nicts-probate-solicitor-sandbox.london.cloudapps.digital/Caveat"; + break; + + case "Staging": + urlToReturn = "https://nicts-probate-solicitor-staging.london.cloudapps.digital/Caveat"; + break; + + case "Production": + urlToReturn = "https://apply-for-probate-professional.nidirect.gov.uk/Caveat"; + break; + + default: + break; + } + + return urlToReturn; + } } } \ No newline at end of file diff --git a/Views/Caveat/Question.cshtml b/Views/Caveat/Question.cshtml new file mode 100644 index 0000000..191f0c5 --- /dev/null +++ b/Views/Caveat/Question.cshtml @@ -0,0 +1,38 @@ +@model eligibility_checker.Models.PageViewModel + +
+ @Html.AntiForgeryToken() + + @if (Model.Page != "start") + { + Back + } + + + +
+
+ +

@Model.Header

+
+ + + + +
@Html.Raw(Model.Hint)
+
+
+ + +
+
+ + +
+
+ +
+
+ + \ No newline at end of file diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 3ba1242..a83e3ca 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -12,6 +12,9 @@

Check eligibility for probate +
+
+ Check eligibility for caveat

diff --git a/wwwroot/config/CaveatQuestions.json b/wwwroot/config/CaveatQuestions.json new file mode 100644 index 0000000..00696f0 --- /dev/null +++ b/wwwroot/config/CaveatQuestions.json @@ -0,0 +1,12 @@ +[ + { + "Page": "start", + "Template": "Question", + "Header": "Are you a Solicitor acting on behalf of a client in this application?", + "Validation": "Answer 'Yes' if you are a solicitor, 'No' if you are a citizen applying", + "OnYes": "solicitor-redirect", + "OnNo": "citizen-redirect" + } + + +] \ No newline at end of file