Files
mapo-core/MP-TAB-SERV/Components/NotesMan.razor.cs
T
2023-10-10 11:37:56 +02:00

171 lines
4.4 KiB
C#

using global::Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.Services;
namespace MP_TAB_SERV.Components
{
public partial class NotesMan
{
#region Public Properties
[Parameter]
public MappaStatoExpl? RecMSE { get; set; } = null;
#endregion Public Properties
#region Protected Properties
protected int DurataMin
{
get => _durataMin;
set
{
if (_durataMin != value)
{
_durataMin = value;
var pUpd = Task.Run(async () =>
{
await ReloadFnq();
});
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
protected int NumComm
{
get => numComm;
set
{
if (numComm != value)
{
numComm = value;
var pUpd = Task.Run(async () =>
{
await ReloadComments();
});
pUpd.Wait();
}
}
}
protected int NumGiorni
{
get => _numGiorni;
set
{
if (_numGiorni != value)
{
_numGiorni = value;
var pUpd = Task.Run(async () =>
{
await ReloadFnq();
});
pUpd.Wait();
}
}
}
protected List<CommentiModel>? RecordListComments { get; set; } = new List<CommentiModel>();
protected List<FermiNonQualModel> RecordListFnq { get; set; } = new List<FermiNonQualModel>();
[Inject]
protected TabDataService TabServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task DeteleRec(CommentiModel currRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare il record?"))
return;
RecordListComments = null;
await Task.Delay(1);
await TabServ.EvListDelete(currRec.IdxMacchina, currRec.InizioStato, currRec.IdxTipo);
// ricarico
await ReloadComments();
await ReloadFnq();
}
protected async Task EditRec(CommentiModel currRec)
{
await Task.Delay(1);
currEv = new EventListModel()
{
InizioStato = currRec.InizioStato,
Value = currRec.Value
};
}
protected override async Task OnParametersSetAsync()
{
await ReloadComments();
await ReloadFnq();
}
protected EventListModel? currEv { get; set; } = null;
#endregion Protected Methods
#region Private Properties
private int _durataMin { get; set; } = 5;
private int _numGiorni { get; set; } = 1;
private int numComm { get; set; } = 5;
#endregion Private Properties
#region Private Methods
private async Task DoUpdate(bool forceReload)
{
if (forceReload)
{
currEv = null;
await ReloadComments();
}
}
private async Task ReloadComments()
{
RecordListComments = await TabServ.CommentiGetLastByMacc(RecMSE?.IdxMacchina, NumComm);
}
private async Task ReloadFnq()
{
RecordListFnq = await TabServ.FermiNonQualificatiFilt(RecMSE?.IdxMacchina, NumGiorni, DurataMin);
}
private string setSemaforo(string sem)
{
string answ = "";
if (sem == "sBl")
{
answ = "bg-primary text-warning";
}
else if (sem == "sGr")
{
answ = "bg-secondary text-dark";
}
else if (sem == "sGi")
{
answ = "bg-warning text-dark";
}
return answ;
}
#endregion Private Methods
}
}