Files
limanapp/LiMan.UI/Components/ListInstallazioni.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

172 lines
4.0 KiB
C#

using LiMan.DB.DBModels;
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 ListInstallazioni : ComponentBase, IDisposable
{
#region Public Methods
public string checkSelect(string CodInst)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.CodInst == CodInst) ? "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 AddNew()
{
currRecord = new InstallazioneModel()
{
CodInst = "NewSoftware",
Cliente = "Nuovo Cliente",
Descrizione = "Descrizione Nuovo Cliente",
Contatto = "Contatto",
Email = "info@egalware.com"
};
}
protected void Edit(InstallazioneModel selRecord)
{
currRecord = selRecord;
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task SetNumRec(int newNum)
{
currPage = 1;
numRecord = newNum;
await ReloadAllData();
isLoading = false;
}
protected async Task SetPageNum(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 InstallazioneModel currRecord = null;
private List<InstallazioneModel> ListRecords;
private List<InstallazioneModel> 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.InstallazioniNextGetAll();
totalCount = SearchRecords.Count();
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
}
}