diff --git a/Helios/Models/ConfiguratorResult.cs b/Helios/Models/ConfiguratorResult.cs index 879680482aa96fb4bfa4ce46663b75ec39236515..cb7ad1f834a7a76f8796b5115b3fad2bc82f9af1 100644 --- a/Helios/Models/ConfiguratorResult.cs +++ b/Helios/Models/ConfiguratorResult.cs @@ -3,8 +3,28 @@ using System.ComponentModel; namespace Helios.Models { - public class ConfiguratorResult - { + public class ConfiguratorResult + { + public List<RoofResults> RoofResults { get; set; } + + public ConfiguratorResult() { + RoofResults = new List<RoofResults>(); + } + } + + public class RoofResults + { + public List<PanelPerformance> Panels { get; set; } + public double RoofAngle { get; set; } + public double RoofArea { get; set; } + + public RoofResults() { + Panels = new List<PanelPerformance>(); + } + } + + public class PanelPerformance + { public double RoofArea { get; set; } public double RoofAngle { get; set; } @@ -29,9 +49,7 @@ namespace Helios.Models [DisplayName("Is Within Budget")] public bool WithinBudget { get; set; } - public ConfiguratorResult() - { - } - } + public PanelPerformance() { } + } } diff --git a/Helios/Source/ConfiguratorService.cs b/Helios/Source/ConfiguratorService.cs index 96c2206d618e81ef94e032568a7fe927020f51d2..ecc8ab1fd0bbe0ba199b0f3aafe21407206f48c3 100644 --- a/Helios/Source/ConfiguratorService.cs +++ b/Helios/Source/ConfiguratorService.cs @@ -18,37 +18,47 @@ namespace Helios.Source this._maxElevation = GetSunElevation(); } - public List<ConfiguratorResult> GetResults(ConfiguratorInput input) + public ConfiguratorResult GetResults(ConfiguratorInput input) { - List<ConfiguratorResult> results = new List<ConfiguratorResult>(); + ConfiguratorResult result = new ConfiguratorResult(); - foreach (SolarPanel panel in _solarPanels) + foreach (Roof roof in input.Roofs) { - foreach (Roof roof in input.Roofs) - { - ConfiguratorResult result = new ConfiguratorResult(); + RoofResults roofResult = new RoofResults(); + + roofResult.RoofAngle = roof.Elevation; + roofResult.RoofArea = roof.Area; + + foreach (SolarPanel panel in _solarPanels) + { + PanelPerformance performance = new PanelPerformance(); int summerElevationAngle = roof.GetElevationAngle(_maxElevation.SummerElevation); int winterElevationAngle = roof.GetElevationAngle(_maxElevation.WinterElevation); - result.RoofArea = roof.Area; - result.RoofAngle = roof.Elevation; - result.PanelEfficiency = panel.Efficiency * 100; - result.InstallationCost = panel.GetInstallationCost(roof.Area); - result.PowerGeneratedSummer = Math.Round(panel.GetPowerOutput(1000, roof.Area, summerElevationAngle), 2); - result.PowerGeneratedWinter = Math.Round(panel.GetPowerOutput(1000, roof.Area, winterElevationAngle), 2); - result.GeneratesRequiredPower = GeneratesRequiredPower(input.PowerRequired, result.PowerGeneratedWinter); - result.ExceedsMaximumPower = ExceedsPowerLimit(input.MaximumPower, result.PowerGeneratedWinter); - result.WithinBudget = WithinBudget(input.Budget, result.InstallationCost); - - if (result.RoofAngle != 0) + performance.RoofArea = roof.Area; + performance.RoofAngle = roof.Elevation; + performance.PanelEfficiency = panel.Efficiency * 100; + performance.InstallationCost = panel.GetInstallationCost(roof.Area); + performance.PowerGeneratedSummer = Math.Round(panel.GetPowerOutput(1000, roof.Area, summerElevationAngle), 2); + performance.PowerGeneratedWinter = Math.Round(panel.GetPowerOutput(1000, roof.Area, winterElevationAngle), 2); + performance.GeneratesRequiredPower = GeneratesRequiredPower(input.PowerRequired, performance.PowerGeneratedWinter); + performance.ExceedsMaximumPower = ExceedsPowerLimit(input.MaximumPower, performance.PowerGeneratedWinter); + performance.WithinBudget = WithinBudget(input.Budget, performance.InstallationCost); + + if (performance.RoofAngle != 0) { - results.Add(result); + roofResult.Panels.Add(performance); } } + + if (roofResult.Panels.Count != 0) + { + result.RoofResults.Add(roofResult); + } } - return results; + return result; } private bool WithinBudget(int budget, double installationCost) diff --git a/Helios/Views/Configurator/ConfiguratorResult.cshtml b/Helios/Views/Configurator/ConfiguratorResult.cshtml index 8ca3354aa22f89a25f5057576bcf48f71b2806c7..bb9acf50173f8ff3188bc51cb8efd831e974a172 100644 --- a/Helios/Views/Configurator/ConfiguratorResult.cshtml +++ b/Helios/Views/Configurator/ConfiguratorResult.cshtml @@ -1,63 +1,73 @@ -@model IEnumerable<Helios.Models.ConfiguratorResult> +@model Helios.Models.ConfiguratorResult @{ ViewData["Title"] = "Configuration Results"; } -<h4>Configurator Results</h4> -<hr /> +@foreach (var roofResult in Model.RoofResults) + { + <h5>Results for roof:</h5> -<table class="table"> - <tr> - <th> - @Html.DisplayNameFor(model => model.PanelEfficiency) - </th> - <th> - @Html.DisplayNameFor(model => model.InstallationCost) - </th> - <th> - @Html.DisplayNameFor(model => model.PowerGeneratedSummer) - </th> - <th> - @Html.DisplayNameFor(model => model.PowerGeneratedWinter) - </th> - <th> - @Html.DisplayNameFor(model => model.GeneratesRequiredPower) - </th> - <th> - @Html.DisplayNameFor(model => model.ExceedsMaximumPower) - </th> - <th> - @Html.DisplayNameFor(model => model.WithinBudget) - </th> - <th></th> - </tr> + <ul> + <li> + Area: @roofResult.RoofArea + </li> + <li> + Angle: @roofResult.RoofAngle + </li> + </ul> - @foreach (var item in Model) - { - <tr> - <td> - @Html.DisplayFor(modelItem => item.PanelEfficiency) - </td> - <td> - @Html.DisplayFor(modelItem => item.InstallationCost) - </td> - <td> - @Html.DisplayFor(modelItem => item.PowerGeneratedSummer) - </td> - <td> - @Html.DisplayFor(modelItem => item.PowerGeneratedWinter) - </td> - <td> - @Html.DisplayFor(modelItem => item.GeneratesRequiredPower) - </td> - <td> - @Html.DisplayFor(modelItem => item.ExceedsMaximumPower) - </td> - <td> - @Html.DisplayFor(modelItem => item.WithinBudget) - </td> - </tr> - } + <table class="table"> + <tr> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PanelEfficiency) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].InstallationCost) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PowerGeneratedSummer) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PowerGeneratedWinter) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].GeneratesRequiredPower) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].ExceedsMaximumPower) + </th> + <th> + @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].WithinBudget) + </th> + </tr> + + @foreach (var panel in roofResult.Panels) + { + <tr> + <td> + @panel.PanelEfficiency + </td> + <td> + @panel.InstallationCost + </td> + <td> + @panel.PowerGeneratedSummer + </td> + <td> + @panel.PowerGeneratedWinter + </td> + <td> + @panel.GeneratesRequiredPower + </td> + <td> + @panel.ExceedsMaximumPower + </td> + <td> + @panel.WithinBudget + </td> + </tr> + } -</table> \ No newline at end of file + </table> + } \ No newline at end of file