Normalize II

This commit is contained in:
Mike Phares 2023-02-01 23:15:14 -07:00
parent cb37f3d996
commit 9def988f9d
6 changed files with 54 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -0,0 +1,18 @@
@page "/Calculator"
@using Microsoft.AspNetCore.Components.Web
@using MudBlazor
@namespace Normalize.ClientHub.Pages
<PageTitle>Calculator</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Calculator</MudText>
<MudTextField Label="VIN" @bind-Value="_VIN"></MudTextField>
<MudTextField Label="Miles" @bind-Value="_Miles"></MudTextField>
<MudTextField Label="BasePrice" @bind-Value="_BasePrice"></MudTextField>
<MudTextField Label="OutTheDoor" @bind-Value="_OutTheDoor"></MudTextField>
<MudTextField Label="Value" @bind-Value="_Value"></MudTextField>
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="Calculate">Calculate</MudButton>

View File

@ -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<Calculator>? 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);
}
}

View File

@ -6,4 +6,5 @@
<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
<MudNavLink Href="calculator" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Calculator</MudNavLink>
</MudNavMenu>

View File

@ -3,6 +3,7 @@
"ApiUrl": "http://localhost:50199",
"BuildNumber": "1",
"Company": "Mike Phares",
"ExpectedMileage": 180000,
"GitCommitSeven": "1234567",
"IsDevelopment": false,
"IsStaging": false,