Skip to content

Commit

Permalink
PC-770: Auto format changed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn-Clarke committed Jan 9, 2025
1 parent 200d382 commit 45d8d2e
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -561,46 +561,21 @@ private static bool GetBreOutsideSpace(HasOutdoorSpace? hasOutdoorSpace)

private static int? GetBreHeatingControls(List<HeatingControls> 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");
}
Expand Down
19 changes: 14 additions & 5 deletions SeaPublicWebsite.BusinessLogic/Models/Enums/HeatingControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion SeaPublicWebsite.BusinessLogic/Models/PropertyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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> HeatingControls { get; set; } = [];

public HasHotWaterCylinder? HasHotWaterCylinder { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion SeaPublicWebsite.BusinessLogic/PropertyDataUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public QuestionFlowStep UpdateOtherHeatingType(
QuestionFlowStep.OtherHeatingType,
entryPoint);
}

public QuestionFlowStep UpdateHeatingControls(
PropertyData propertyData,
List<HeatingControls> heatingControls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
{
Expand Down
8 changes: 4 additions & 4 deletions SeaPublicWebsite/Controllers/EnergyEfficiencyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ public async Task<IActionResult> OtherHeatingType_Post(OtherHeatingTypeViewModel

return RedirectToNextStep(nextStep, viewModel.Reference, viewModel.EntryPoint);
}

[HttpGet("heating-controls/{reference}")]
public async Task<IActionResult> HeatingControls_Get(string reference, QuestionFlowStep? entryPoint = null)
{
Expand All @@ -1088,7 +1088,7 @@ public async Task<IActionResult> HeatingControls_Get(string reference, QuestionF

return View("HeatingControls", viewModel);
}

[HttpPost("heating-controls/{reference}")]
public async Task<IActionResult> HeatingControls_Post(HeatingControlsViewModel viewModel)
{
Expand All @@ -1097,12 +1097,12 @@ public async Task<IActionResult> 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);
}

Expand Down
3 changes: 1 addition & 2 deletions SeaPublicWebsite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;

namespace SeaPublicWebsite.Controllers;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 7 additions & 7 deletions SeaPublicWebsite/Views/EnergyEfficiency/AnswerSummary.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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<SummaryListRowActionItemViewModel>
{
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
}
Expand Down
90 changes: 45 additions & 45 deletions SeaPublicWebsite/Views/EnergyEfficiency/HeatingControls.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<form action="@Url.Action(nameof(EnergyEfficiencyController.HeatingControls_Post), "EnergyEfficiency", new {reference = Model.Reference})" method="post" novalidate>
@(Html.HiddenFor(m => m.EntryPoint))
@Html.AntiForgeryToken()

@{
Func<object, object> details =
@<text>
<p class="govuk-body">
@SharedLocalizer["SmartHeatingControlsHelpString"]
</p>
</text>;
}
<form action="@Url.Action(nameof(EnergyEfficiencyController.HeatingControls_Post), "EnergyEfficiency", new { reference = Model.Reference })" method="post" novalidate>
@(Html.HiddenFor(m => m.EntryPoint))
@Html.AntiForgeryToken()

@(await Html.GovUkCheckboxesFor(m => m.HeatingControls,
fieldsetOptions: new FieldsetViewModel
{
Legend = new LegendViewModel
@{
Func<object, object> details =
@<text>
<p class="govuk-body">
@SharedLocalizer["SmartHeatingControlsHelpString"]
</p>
</text>;
}

@(await Html.GovUkCheckboxesFor(m => m.HeatingControls,
fieldsetOptions: new FieldsetViewModel
{
Text = @SharedLocalizer["HeatingControlsQuestionString"].Value,
Classes = "govuk-fieldset__legend--l",
IsPageHeading = true
}
},
hintOptions: new HintViewModel
{
Html = @<text>
@await Html.GovUkDetails(new DetailsViewModel
{
SummaryText = @SharedLocalizer["HelpMeAnswerHeatingControlsString"].Value,
Html = details
})
</text>
},
dividerOptions: new Dictionary<HeatingControls, string>
Legend = new LegendViewModel
{
Text = SharedLocalizer["HeatingControlsQuestionString"].Value,
Classes = "govuk-fieldset__legend--l",
IsPageHeading = true
}
},
hintOptions: new HintViewModel
{
Html = @<text>
@await Html.GovUkDetails(new DetailsViewModel
{
SummaryText = SharedLocalizer["HelpMeAnswerHeatingControlsString"].Value,
Html = details
})
</text>
},
dividerOptions: new Dictionary<HeatingControls, string>
{
[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
})

</form>

</div>
<div class="govuk-grid-column-one-third">
@await Html.PartialAsync("/Views/EnergyEfficiency/Partials/_AdditionalSupport.cshtml")
Expand Down

0 comments on commit 45d8d2e

Please sign in to comment.