diff --git a/Normalize/ClientHub/Models/AppSettings.cs b/Normalize/ClientHub/Models/AppSettings.cs index fa70a47..c7c8179 100644 --- a/Normalize/ClientHub/Models/AppSettings.cs +++ b/Normalize/ClientHub/Models/AppSettings.cs @@ -5,6 +5,7 @@ namespace Normalize.ClientHub.Models; public record AppSettings(string ApiUrl, string BuildNumber, string Company, + int ExpectedMileage, string GitCommitSeven, bool IsDevelopment, bool IsStaging, diff --git a/Normalize/ClientHub/Models/Binder/AppSettings.cs b/Normalize/ClientHub/Models/Binder/AppSettings.cs index 0b26fbe..3823ab1 100644 --- a/Normalize/ClientHub/Models/Binder/AppSettings.cs +++ b/Normalize/ClientHub/Models/Binder/AppSettings.cs @@ -11,6 +11,7 @@ public class AppSettings [Display(Name = "Api Url"), Required] public string ApiUrl { get; set; } [Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } [Display(Name = "Company"), Required] public string Company { get; set; } + [Display(Name = "Expected Mileage"), Required] public int? ExpectedMileage { get; set; } [Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } [Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } @@ -36,6 +37,8 @@ public class AppSettings throw new NullReferenceException(nameof(BuildNumber)); if (appSettings.Company is null) throw new NullReferenceException(nameof(Company)); + if (appSettings.ExpectedMileage is null) + throw new NullReferenceException(nameof(ExpectedMileage)); if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); if (appSettings.IsDevelopment is null) @@ -50,6 +53,7 @@ public class AppSettings appSettings.ApiUrl, appSettings.BuildNumber, appSettings.Company, + appSettings.ExpectedMileage.Value, appSettings.GitCommitSeven, appSettings.IsDevelopment.Value, appSettings.IsStaging.Value, diff --git a/Normalize/ClientHub/Pages/Calculator.razor b/Normalize/ClientHub/Pages/Calculator.razor new file mode 100644 index 0000000..17f011f --- /dev/null +++ b/Normalize/ClientHub/Pages/Calculator.razor @@ -0,0 +1,18 @@ +@page "/Calculator" + +@using Microsoft.AspNetCore.Components.Web +@using MudBlazor + +@namespace Normalize.ClientHub.Pages + +Calculator + +Calculator + + + + + + + +Calculate \ No newline at end of file diff --git a/Normalize/ClientHub/Pages/Calculator.razor.cs b/Normalize/ClientHub/Pages/Calculator.razor.cs new file mode 100644 index 0000000..9d44fec --- /dev/null +++ b/Normalize/ClientHub/Pages/Calculator.razor.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Components; +using Normalize.ClientHub.Models; + +namespace Normalize.ClientHub.Pages; + +public partial class Calculator +{ + + private int _VIN = 0; + private decimal _Value = 0; + private int _Miles = 107228; + private decimal _BasePrice = 12816; + private decimal _OutTheDoor = 15801.34m; + + [Inject] protected AppSettings? AppSettings { get; set; } + [Inject] protected ILogger? Logger { get; set; } + + protected override void OnParametersSet() => Calculate(); + + private void Calculate() + { + if (Logger is null) + throw new NullReferenceException(nameof(Logger)); + if (AppSettings is null) + throw new NullReferenceException(nameof(AppSettings)); + _Value = _OutTheDoor / (AppSettings.ExpectedMileage - _Miles); + } + +} \ No newline at end of file diff --git a/Normalize/ClientHub/Shared/NavMenu.razor b/Normalize/ClientHub/Shared/NavMenu.razor index 75929b0..8f231f6 100644 --- a/Normalize/ClientHub/Shared/NavMenu.razor +++ b/Normalize/ClientHub/Shared/NavMenu.razor @@ -6,4 +6,5 @@ Home Counter + Calculator \ No newline at end of file diff --git a/Normalize/ClientHub/appsettings.json b/Normalize/ClientHub/appsettings.json index 4af4738..31aaac5 100644 --- a/Normalize/ClientHub/appsettings.json +++ b/Normalize/ClientHub/appsettings.json @@ -3,6 +3,7 @@ "ApiUrl": "http://localhost:50199", "BuildNumber": "1", "Company": "Mike Phares", + "ExpectedMileage": 180000, "GitCommitSeven": "1234567", "IsDevelopment": false, "IsStaging": false,