Files
mapo-core/MP.Stats/Pages/Scarti.razor.cs
T
2021-05-17 15:05:40 +02:00

104 lines
2.7 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Stats.Data;
using System;
using System.Threading.Tasks;
namespace MP.Stats.Pages
{
public partial class Scarti : ComponentBase, IDisposable
{
#region Private Fields
private MP.Data.DatabaseModels.ResScarti currRecord = null;
private MP.Data.DatabaseModels.ResScarti[] ListRecords;
#endregion Private Fields
#region Private Properties
private int numRecord { get; set; } = 10;
#endregion Private Properties
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
[Inject]
protected MpStatsService StatService { get; set; }
#endregion Protected Properties
#region Protected Methods
protected async Task ForceReload(int newNum)
{
numRecord = newNum;
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
}
protected override async Task OnInitializedAsync()
{
numRecord = 10;
MessageService.ShowSearch = true;
MessageService.EA_SearchUpdated += OnSeachUpdated;
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
}
protected void ResetData()
{
StatService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task UpdateData()
{
currRecord = null;
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(DateTime DataOra, string IdxMacchina, string Causale)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.DataOra == DataOra && currRecord.IdxMacchina == IdxMacchina && currRecord.Causale == Causale) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public void OnSeachUpdated()
{
InvokeAsync(() =>
{
UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}