94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using Blazored.Modal;
|
|
using Blazored.Modal.Services;
|
|
using Blazored.Toast.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using ReserveManagementSystemLib.Models;
|
|
using ReserveManagementSystemUI.Services;
|
|
using ReserveManagementSystemUI.Shared.Components;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ReserveManagementSystemUI.Pages
|
|
{
|
|
public partial class LoanView : ComponentBase
|
|
{
|
|
[Inject]
|
|
IToastService ToastService { get; set; }
|
|
|
|
[Inject]
|
|
IModalService Modal { get; set; }
|
|
|
|
[Inject]
|
|
ReserveService ReserveService { get; set; }
|
|
|
|
[Parameter]
|
|
public int LoanId { get; set; }
|
|
|
|
private Loan loanDetails = new Loan();
|
|
|
|
private IModalReference openModal;
|
|
|
|
private string LoanTypeDetailString => !string.IsNullOrEmpty(loanDetails.LoanType?.ToString()) ? loanDetails.LoanTypeId?.ToString() + " - " + @loanDetails.LoanType?.LoanComment : "";
|
|
|
|
private string PaidLoanDateString => loanDetails.PaidLoanDate?.ToString("M/d/yyyy");
|
|
|
|
private string ChargeBackString => loanDetails.ChargeBack?.ToString("C");
|
|
|
|
private string StatementDateString => loanDetails.StatementDate?.ToString("M/d/yyyy");
|
|
|
|
private string AdjustmentString => loanDetails.Adjustment?.ToString("C");
|
|
|
|
private string VehicleMileageFormat => loanDetails.Vehicle.Mileage.ToString("#,##0");
|
|
|
|
private string GapString => loanDetails.Gap == true ? "Y" : "N";
|
|
|
|
private string WarrantyString => loanDetails.Warranty == true ? "Y" : "N";
|
|
|
|
private string MbpString => loanDetails.Mbp == true ? "Y" : "N";
|
|
|
|
private string CreditLifeString => loanDetails.CreditLife == true ? "Y" : "N";
|
|
|
|
private string CreditDisabilityString => loanDetails.CreditDisability == true ? "Y" : "N";
|
|
|
|
[CascadingParameter] EditContext EditContext { get; set; }
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
|
|
await LoadLoanDetails();
|
|
}
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
|
|
}
|
|
|
|
private string GetFieldValidationClass(string fieldName)
|
|
{
|
|
string className = "form-control";
|
|
if (loanDetails.ValidationErrors != null) {
|
|
foreach(var error in loanDetails.ValidationErrors)
|
|
{
|
|
if (error.PropertyName == fieldName) {
|
|
return "form-control invalid";
|
|
}
|
|
}
|
|
}
|
|
return className;
|
|
}
|
|
|
|
private async Task LoadLoanDetails()
|
|
{
|
|
openModal = Modal.Show<LoadingSpinner>();
|
|
loanDetails = await ReserveService.GetLoanById(LoanId);
|
|
|
|
if (loanDetails == null)
|
|
{
|
|
ToastService.ShowError("There was an issue retrieving this loan.");
|
|
}
|
|
openModal.Close();
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
}
|