Files
limanapp/LiMan.UI/Components/ListInstallazioniGLS.razor.cs
Samuele Locatelli 5d72d21fb1 Stat installazioni:
Update gestione paginazione (visibile solo dove serve) + fix calcolo di alcuni intems male filtrati
2025-04-03 17:47:31 +02:00

163 lines
3.8 KiB
C#

using LiMan.GLS.DatabaseModels;
using LiMan.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LiMan.UI.Components
{
public partial class ListInstallazioniGLS : ComponentBase, IDisposable
{
#region Public Methods
public string checkSelect(string Installazione)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.Installazione == Installazione) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
}
#endregion Public Methods
#region Protected Fields
protected int totalCount = 0;
#endregion Protected Fields
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected LiManDataService DataService { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected bool showCamera { get; set; } = false;
#endregion Protected Properties
#region Protected Methods
protected void Edit(AnagInstallazioni selRecord)
{
currRecord = selRecord;
}
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Licenze Legacy STW";
AppMService.PageIcon = "fas fa-lock";
await ReloadAllData();
}
protected async Task SetNumRec(int newNum)
{
currPage = 1;
numRecord = newNum;
await ReloadAllData();
isLoading = false;
}
protected async Task SetNumPage(int newNum)
{
currPage = newNum;
await ReloadAllData();
isLoading = false;
}
protected async Task ResetData()
{
await FullReload();
}
protected async Task UpdateData()
{
await FullReload();
}
#endregion Protected Methods
#region Private Fields
private AnagInstallazioni currRecord = null;
private List<AnagInstallazioni> ListRecords;
private List<AnagInstallazioni> SearchRecords;
#endregion Private Fields
#region Private Properties
private int currPage
{
get
{
return AppMService.PageNum;
}
set
{
AppMService.PageNum = value;
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get
{
return AppMService.PageSize;
}
set
{
AppMService.PageSize = value;
}
}
#endregion Private Properties
#region Private Methods
private async Task FullReload()
{
currRecord = null;
await DataService.FlushRedisCache();
await ReloadAllData();
}
private async Task ReloadAllData()
{
isLoading = true;
await Task.Delay(1);
//SearchRecords = null;
SearchRecords = await DataService.InstallazioniGLSGetAll();
totalCount = SearchRecords.Count();
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
}
}