diff --git a/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/BreRequest.cs b/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/BreRequest.cs index b1b373c4..23ad7f7a 100644 --- a/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/BreRequest.cs +++ b/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/BreRequest.cs @@ -35,7 +35,7 @@ public class BreRequest public int? roof_type { get; set; } public bool? pv_panel { get; set; } - + public int? heating_controls { get; set; } public int wall_type { get; set; } diff --git a/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/RecommendationService.cs b/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/RecommendationService.cs index bd0f9099..5c1efb25 100644 --- a/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/RecommendationService.cs +++ b/SeaPublicWebsite.BusinessLogic/ExternalServices/Bre/RecommendationService.cs @@ -149,8 +149,8 @@ private static BreRequest CreateRequest(PropertyData propertyData) BreHeatingSystem breHeatingSystem = GetBreHeatingSystem(propertyData.HeatingType.Value, propertyData.OtherHeatingType); - - int? breHeatingControls = GetBreHeatingControls(propertyData.HeatingControls); + + var breHeatingControls = GetBreHeatingControls(propertyData.HeatingControls); bool? breHotWaterCylinder = GetBreHotWaterCylinder(propertyData.HasHotWaterCylinder); @@ -561,46 +561,21 @@ private static bool GetBreOutsideSpace(HasOutdoorSpace? hasOutdoorSpace) private static int? GetBreHeatingControls(List heatingControls) { - if (heatingControls.Count == 0) - { - return null; - } - if (!heatingControls.Except([HeatingControls.Programmer, HeatingControls.RoomThermostats, HeatingControls.ThermostaticRadiatorValves]).Any()) - { - return 1; - } - if (!heatingControls.Except([HeatingControls.RoomThermostats, HeatingControls.ThermostaticRadiatorValves]).Any()) - { - return 2; - } - if (!heatingControls.Except([HeatingControls.Programmer, HeatingControls.ThermostaticRadiatorValves]).Any()) - { - return 3; - } - if (!heatingControls.Except([HeatingControls.RoomThermostats, HeatingControls.Programmer]).Any()) - { - return 4; - } - if (!heatingControls.Except([HeatingControls.Programmer]).Any()) - { - return 5; - } - if (!heatingControls.Except([HeatingControls.RoomThermostats]).Any()) - { - return 6; - } - if (!heatingControls.Except([HeatingControls.RoomThermostats]).Any()) - { - return 7; - } - if (heatingControls.Contains(HeatingControls.None)) - { - return 8; - } - if (heatingControls.Contains(HeatingControls.DoNotKnow)) - { - return 9; - } + if (heatingControls.Count == 0) return null; + if (!heatingControls.Except([ + HeatingControls.Programmer, HeatingControls.RoomThermostats, + HeatingControls.ThermostaticRadiatorValves + ]).Any()) return 1; + if (!heatingControls.Except([HeatingControls.RoomThermostats, HeatingControls.ThermostaticRadiatorValves]) + .Any()) return 2; + if (!heatingControls.Except([HeatingControls.Programmer, HeatingControls.ThermostaticRadiatorValves]) + .Any()) return 3; + if (!heatingControls.Except([HeatingControls.RoomThermostats, HeatingControls.Programmer]).Any()) return 4; + if (!heatingControls.Except([HeatingControls.Programmer]).Any()) return 5; + if (!heatingControls.Except([HeatingControls.RoomThermostats]).Any()) return 6; + if (!heatingControls.Except([HeatingControls.RoomThermostats]).Any()) return 7; + if (heatingControls.Contains(HeatingControls.None)) return 8; + if (heatingControls.Contains(HeatingControls.DoNotKnow)) return 9; throw new Exception("Invalid HeatingControls answer set"); } diff --git a/SeaPublicWebsite.BusinessLogic/Models/Enums/HeatingControls.cs b/SeaPublicWebsite.BusinessLogic/Models/Enums/HeatingControls.cs index 27c84bee..73099524 100644 --- a/SeaPublicWebsite.BusinessLogic/Models/Enums/HeatingControls.cs +++ b/SeaPublicWebsite.BusinessLogic/Models/Enums/HeatingControls.cs @@ -4,14 +4,23 @@ namespace SeaPublicWebsite.BusinessLogic.Models.Enums; public enum HeatingControls { - [Display(ResourceType = typeof(Resources.Enum.HeatingControls), Description = nameof(Resources.Enum.HeatingControls.Programmer))] + [Display(ResourceType = typeof(Resources.Enum.HeatingControls), + Description = nameof(Resources.Enum.HeatingControls.Programmer))] Programmer, - [Display(ResourceType = typeof(Resources.Enum.HeatingControls), Description = nameof(Resources.Enum.HeatingControls.RoomThermostat))] + + [Display(ResourceType = typeof(Resources.Enum.HeatingControls), + Description = nameof(Resources.Enum.HeatingControls.RoomThermostat))] RoomThermostats, - [Display(ResourceType = typeof(Resources.Enum.HeatingControls), Description = nameof(Resources.Enum.HeatingControls.ThermostaticRadiatorValves))] + + [Display(ResourceType = typeof(Resources.Enum.HeatingControls), + Description = nameof(Resources.Enum.HeatingControls.ThermostaticRadiatorValves))] ThermostaticRadiatorValves, - [Display(ResourceType = typeof(Resources.Enum.HeatingControls), Description = nameof(Resources.Enum.HeatingControls.None))] + + [Display(ResourceType = typeof(Resources.Enum.HeatingControls), + Description = nameof(Resources.Enum.HeatingControls.None))] None, - [Display(ResourceType = typeof(Resources.Enum.HeatingControls), Description = nameof(Resources.Enum.HeatingControls.DoNotKnow))] + + [Display(ResourceType = typeof(Resources.Enum.HeatingControls), + Description = nameof(Resources.Enum.HeatingControls.DoNotKnow))] DoNotKnow } \ No newline at end of file diff --git a/SeaPublicWebsite.BusinessLogic/Models/PropertyData.cs b/SeaPublicWebsite.BusinessLogic/Models/PropertyData.cs index 6490132b..28cf4f91 100644 --- a/SeaPublicWebsite.BusinessLogic/Models/PropertyData.cs +++ b/SeaPublicWebsite.BusinessLogic/Models/PropertyData.cs @@ -45,7 +45,7 @@ public class PropertyData public GlazingType? GlazingType { get; set; } public HeatingType? HeatingType { get; set; } public OtherHeatingType? OtherHeatingType { get; set; } - + public List HeatingControls { get; set; } = []; public HasHotWaterCylinder? HasHotWaterCylinder { get; set; } diff --git a/SeaPublicWebsite.BusinessLogic/PropertyDataUpdater.cs b/SeaPublicWebsite.BusinessLogic/PropertyDataUpdater.cs index 9f8a65cc..930a4c1b 100644 --- a/SeaPublicWebsite.BusinessLogic/PropertyDataUpdater.cs +++ b/SeaPublicWebsite.BusinessLogic/PropertyDataUpdater.cs @@ -321,7 +321,7 @@ public QuestionFlowStep UpdateOtherHeatingType( QuestionFlowStep.OtherHeatingType, entryPoint); } - + public QuestionFlowStep UpdateHeatingControls( PropertyData propertyData, List heatingControls, diff --git a/SeaPublicWebsite.BusinessLogic/Services/QuestionFlowService.cs b/SeaPublicWebsite.BusinessLogic/Services/QuestionFlowService.cs index 47c0e6e6..bb4f432a 100644 --- a/SeaPublicWebsite.BusinessLogic/Services/QuestionFlowService.cs +++ b/SeaPublicWebsite.BusinessLogic/Services/QuestionFlowService.cs @@ -791,7 +791,7 @@ private QuestionFlowStep HeatingControlsForwardDestination(QuestionFlowStep? ent { // If entrypoint is HeatingType, we must ask the other followup question on this route if (entryPoint is QuestionFlowStep.HeatingType) return QuestionFlowStep.HotWaterCylinder; - + return entryPoint is not null ? QuestionFlowStep.AnswerSummary : QuestionFlowStep.HotWaterCylinder; diff --git a/SeaPublicWebsite.UnitTests/BusinessLogic/Models/ResetUnusedFieldsTests.cs b/SeaPublicWebsite.UnitTests/BusinessLogic/Models/ResetUnusedFieldsTests.cs index 4097a2a3..96b15b39 100644 --- a/SeaPublicWebsite.UnitTests/BusinessLogic/Models/ResetUnusedFieldsTests.cs +++ b/SeaPublicWebsite.UnitTests/BusinessLogic/Models/ResetUnusedFieldsTests.cs @@ -2,7 +2,6 @@ using NUnit.Framework; using SeaPublicWebsite.BusinessLogic.Models; using SeaPublicWebsite.BusinessLogic.Models.Enums; -using HeatingControls = SeaPublicWebsite.BusinessLogic.Resources.Enum.HeatingControls; namespace Tests.BusinessLogic.Models; @@ -234,7 +233,7 @@ public void RunResetUnusedFieldTestCases(ResetUnusedFieldsTestCase testCase) HeatingType = HeatingType.Storage, OtherHeatingType = OtherHeatingType.Biomass, HasHotWaterCylinder = HasHotWaterCylinder.Yes, - HeatingControls = [SeaPublicWebsite.BusinessLogic.Models.Enums.HeatingControls.Programmer, SeaPublicWebsite.BusinessLogic.Models.Enums.HeatingControls.RoomThermostats] + HeatingControls = [HeatingControls.Programmer, HeatingControls.RoomThermostats] }, new() { diff --git a/SeaPublicWebsite/Controllers/EnergyEfficiencyController.cs b/SeaPublicWebsite/Controllers/EnergyEfficiencyController.cs index f3491e78..20e7c581 100644 --- a/SeaPublicWebsite/Controllers/EnergyEfficiencyController.cs +++ b/SeaPublicWebsite/Controllers/EnergyEfficiencyController.cs @@ -1072,7 +1072,7 @@ public async Task OtherHeatingType_Post(OtherHeatingTypeViewModel return RedirectToNextStep(nextStep, viewModel.Reference, viewModel.EntryPoint); } - + [HttpGet("heating-controls/{reference}")] public async Task HeatingControls_Get(string reference, QuestionFlowStep? entryPoint = null) { @@ -1088,7 +1088,7 @@ public async Task HeatingControls_Get(string reference, QuestionF return View("HeatingControls", viewModel); } - + [HttpPost("heating-controls/{reference}")] public async Task HeatingControls_Post(HeatingControlsViewModel viewModel) { @@ -1097,12 +1097,12 @@ public async Task HeatingControls_Post(HeatingControlsViewModel v Console.WriteLine(ModelState.ValidationState); return await HeatingControls_Get(viewModel.Reference, viewModel.EntryPoint); } - + var nextStep = await answerService.UpdateHeatingControls( viewModel.Reference, viewModel.HeatingControls, viewModel.EntryPoint); - + return RedirectToNextStep(nextStep, viewModel.Reference, viewModel.EntryPoint); } diff --git a/SeaPublicWebsite/Controllers/HomeController.cs b/SeaPublicWebsite/Controllers/HomeController.cs index 7ba23d26..dbaec02f 100644 --- a/SeaPublicWebsite/Controllers/HomeController.cs +++ b/SeaPublicWebsite/Controllers/HomeController.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace SeaPublicWebsite.Controllers; diff --git a/SeaPublicWebsite/Models/EnergyEfficiency/HeatingControlsViewModel.cs b/SeaPublicWebsite/Models/EnergyEfficiency/HeatingControlsViewModel.cs index 89cb4f6d..a4f3d9eb 100644 --- a/SeaPublicWebsite/Models/EnergyEfficiency/HeatingControlsViewModel.cs +++ b/SeaPublicWebsite/Models/EnergyEfficiency/HeatingControlsViewModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using GovUkDesignSystem.Attributes.ValidationAttributes; using GovUkDesignSystem.ModelBinders; using Microsoft.AspNetCore.Mvc; diff --git a/SeaPublicWebsite/Views/EnergyEfficiency/AnswerSummary.cshtml b/SeaPublicWebsite/Views/EnergyEfficiency/AnswerSummary.cshtml index 75ef96d5..100ca6b9 100644 --- a/SeaPublicWebsite/Views/EnergyEfficiency/AnswerSummary.cshtml +++ b/SeaPublicWebsite/Views/EnergyEfficiency/AnswerSummary.cshtml @@ -404,29 +404,29 @@ } } }); - + if (Model.PropertyData.HeatingControls is not null && Model.PropertyData.HeatingControls.Count > 0) { - rows.Add(new() + rows.Add(new SummaryListRowViewModel { - Key = new() + Key = new SummaryListRowKey { Classes = "govuk-!-width-one-quarter", Text = SharedLocalizer["HeatingControlsQuestionString"].Value }, - Value = new() + Value = new SummaryListRowValue { Classes = "govuk-!-width-one-half", Text = string.Join(", ", Model.PropertyData.HeatingControls.Select(x => GovUkRadioCheckboxLabelTextAttribute.GetLabelText(x))) }, - Actions = new() + Actions = new SummaryListRowActionViewModel { Classes = "govuk-!-width-one-quarter", - Items = new() + Items = new List { new() { - Href = Url.Action(nameof(EnergyEfficiencyController.HeatingControls_Get), "EnergyEfficiency", new {reference = Model.PropertyData.Reference, entryPoint = QuestionFlowStep.HeatingControls}), + Href = Url.Action(nameof(EnergyEfficiencyController.HeatingControls_Get), "EnergyEfficiency", new { reference = Model.PropertyData.Reference, entryPoint = QuestionFlowStep.HeatingControls }), Text = SharedLocalizer["Change"].Value, VisuallyHiddenText = SharedLocalizer["HeatingControlsQuestionString"].Value } diff --git a/SeaPublicWebsite/Views/EnergyEfficiency/HeatingControls.cshtml b/SeaPublicWebsite/Views/EnergyEfficiency/HeatingControls.cshtml index 844089a0..f5c31635 100644 --- a/SeaPublicWebsite/Views/EnergyEfficiency/HeatingControls.cshtml +++ b/SeaPublicWebsite/Views/EnergyEfficiency/HeatingControls.cshtml @@ -8,65 +8,65 @@ @model SeaPublicWebsite.Models.EnergyEfficiency.HeatingControlsViewModel; @{ - ViewBag.Title = @SharedLocalizer["Heating Controls"].Value; + ViewBag.Title = SharedLocalizer["Heating Controls"].Value; } @section BeforeMain { @await Html.GovUkBackLink(new BackLinkViewModel - { - Text = @SharedLocalizer["Back"].Value, - Href = Model.BackLink - }) + { + Text = SharedLocalizer["Back"].Value, + Href = Model.BackLink + }) }
- -
- @(Html.HiddenFor(m => m.EntryPoint)) - @Html.AntiForgeryToken() - @{ - Func details = - @ -

- @SharedLocalizer["SmartHeatingControlsHelpString"] -

-
; - } + + @(Html.HiddenFor(m => m.EntryPoint)) + @Html.AntiForgeryToken() - @(await Html.GovUkCheckboxesFor(m => m.HeatingControls, - fieldsetOptions: new FieldsetViewModel - { - Legend = new LegendViewModel + @{ + Func details = + @ +

+ @SharedLocalizer["SmartHeatingControlsHelpString"] +

+
; + } + + @(await Html.GovUkCheckboxesFor(m => m.HeatingControls, + fieldsetOptions: new FieldsetViewModel { - Text = @SharedLocalizer["HeatingControlsQuestionString"].Value, - Classes = "govuk-fieldset__legend--l", - IsPageHeading = true - } - }, - hintOptions: new HintViewModel - { - Html = @ - @await Html.GovUkDetails(new DetailsViewModel - { - SummaryText = @SharedLocalizer["HelpMeAnswerHeatingControlsString"].Value, - Html = details - }) - - }, - dividerOptions: new Dictionary + Legend = new LegendViewModel + { + Text = SharedLocalizer["HeatingControlsQuestionString"].Value, + Classes = "govuk-fieldset__legend--l", + IsPageHeading = true + } + }, + hintOptions: new HintViewModel + { + Html = @ + @await Html.GovUkDetails(new DetailsViewModel + { + SummaryText = SharedLocalizer["HelpMeAnswerHeatingControlsString"].Value, + Html = details + }) + + }, + dividerOptions: new Dictionary + { + [HeatingControls.None] = SharedLocalizer["or"].Value + })) + + @await Html.GovUkButton(new ButtonViewModel { - [HeatingControls.None] = SharedLocalizer["or"].Value - })) + Text = SharedLocalizer["Continue"].Value + }) - @await Html.GovUkButton(new ButtonViewModel - { - Text = @SharedLocalizer["Continue"].Value - }) - - +
@await Html.PartialAsync("/Views/EnergyEfficiency/Partials/_AdditionalSupport.cshtml")