Files
mapo-mono/MP.MONO.UI/Components/PrevMaintTask.razor.cs
T
2022-06-11 19:16:29 +02:00

152 lines
3.6 KiB
C#

using MP.MONO.Data.DbModels;
namespace MP.MONO.UI.Components
{
public partial class PrevMaintTask
{
#region Private Fields
private int _MaxRecord = 200;
private bool doSetup = false;
private List<PrevMaintTaskModel>? ListRecords = null;
// FARE!!! filtro macchina
private int MachineId = 1;
private List<PrevMaintTaskModel>? SearchRecords = null;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
currPMTaskId = 0;
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int currPMTaskId { get; set; } = 0;
private bool isLoading { get; set; } = false;
private string mainCssClass
{
get => currPMTaskId == 0 ? "col-12" : "col-8";
}
private int MaxRecord
{
get
{
return _MaxRecord;
}
set
{
if (_MaxRecord != value)
{
_MaxRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
currPMTaskId = 0;
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Private Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Methods
private string checkSel(int PMTaskId)
{
return PMTaskId == currPMTaskId ? "table-primary" : "";
}
private void ForceReload(int newNum)
{
numRecord = newNum;
}
private void ForceReloadPage(int newNum)
{
currPage = newNum;
}
private async Task ReloadData()
{
isLoading = true;
ListRecords = null;
await Task.Delay(1);
SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
isLoading = false;
}
private async Task ShowDetail(int PMTaskId)
{
currPMTaskId = PMTaskId;
//await ReloadData();
await Task.Delay(1);
}
/// <summary>
/// Solelva evento cambio modo (Pending/Scheduled)
/// </summary>
private void ChangeMode()
{
}
#endregion Private Methods
}
}