Normalize II
This commit is contained in:
18
Normalize/ClientHub/Pages/Calculator.razor
Normal file
18
Normalize/ClientHub/Pages/Calculator.razor
Normal 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>
|
||||
29
Normalize/ClientHub/Pages/Calculator.razor.cs
Normal file
29
Normalize/ClientHub/Pages/Calculator.razor.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user