From 86f41bdf29afad76a8d6b3e29f9c8c9c069a4f00 Mon Sep 17 00:00:00 2001
From: Dan <daniel2.lorych@live.uwe.ac.uk>
Date: Wed, 4 May 2022 20:58:15 +0100
Subject: [PATCH] Add cost per watt to results

---
 Helios/Models/ConfiguratorResult.cs                 | 3 +++
 Helios/Source/ConfiguratorService.cs                | 1 +
 Helios/Views/Configurator/ConfiguratorResult.cshtml | 6 ++++++
 Helios/Views/Configurator/PanelDetails.cshtml       | 3 +++
 4 files changed, 13 insertions(+)

diff --git a/Helios/Models/ConfiguratorResult.cs b/Helios/Models/ConfiguratorResult.cs
index c32aa18..a7879ab 100644
--- a/Helios/Models/ConfiguratorResult.cs
+++ b/Helios/Models/ConfiguratorResult.cs
@@ -52,6 +52,9 @@ namespace Helios.Models
         [DisplayName("Is Within Budget")]
         public bool WithinBudget { get; set; }
 
+        [DisplayName("Cost Per Watt (£ / W)")]
+        public double CostPerWatt { get; set; }
+
         public PanelPerformance() { }
     }
 }
diff --git a/Helios/Source/ConfiguratorService.cs b/Helios/Source/ConfiguratorService.cs
index 269cc48..705f290 100644
--- a/Helios/Source/ConfiguratorService.cs
+++ b/Helios/Source/ConfiguratorService.cs
@@ -48,6 +48,7 @@ namespace Helios.Source
 					performance.GeneratesRequiredPower = GeneratesRequiredPower(input.PowerRequired, performance.PowerGeneratedWinter);
 					performance.ExceedsMaximumPower = ExceedsPowerLimit(input.MaximumPower, performance.PowerGeneratedWinter);
 					performance.WithinBudget = WithinBudget(input.Budget, performance.InstallationCost);
+					performance.CostPerWatt = Math.Round(panel.GetCostPerWatt(), 2);
 
 					if (performance.RoofAngle != 0)
 					{
diff --git a/Helios/Views/Configurator/ConfiguratorResult.cshtml b/Helios/Views/Configurator/ConfiguratorResult.cshtml
index fa31e63..f1a306d 100644
--- a/Helios/Views/Configurator/ConfiguratorResult.cshtml
+++ b/Helios/Views/Configurator/ConfiguratorResult.cshtml
@@ -41,6 +41,9 @@
             <th>
                 @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].WithinBudget)
             </th>
+            <th>
+                @Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].CostPerWatt)
+            </th>
             <th>
             </th>
         </tr>
@@ -69,6 +72,9 @@
                     <td>
                         @panel.WithinBudget
                     </td>
+                    <td>
+                        £@panel.CostPerWatt
+                    </td>
                     <td>
                         @Html.ActionLink("Details", "PanelDetails", "Configurator", panel, null)
                     </td>
diff --git a/Helios/Views/Configurator/PanelDetails.cshtml b/Helios/Views/Configurator/PanelDetails.cshtml
index 510fe74..24e82c5 100644
--- a/Helios/Views/Configurator/PanelDetails.cshtml
+++ b/Helios/Views/Configurator/PanelDetails.cshtml
@@ -19,6 +19,9 @@
             <li>
                 Installation Cost: £@Model.InstallationCost
             </li>
+            <li>
+                Cost Per Watt: £@Model.CostPerWatt
+            </li>
         </ul>
     </div>
     <div class="roofDetails">
-- 
GitLab