Files
limanapp/LiMan.UI/Components/ListInstallazioniGLS.razor.cs
T
2024-07-12 15:17:45 +02:00

162 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 Private Fields
private AnagInstallazioni currRecord = null;
private List<AnagInstallazioni> ListRecords;
private List<AnagInstallazioni> SearchRecords;
#endregion Private Fields
#region Protected Fields
protected int totalCount = 0;
#endregion Protected 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 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 Private Methods
private async Task fullReload()
{
currRecord = null;
await DataService.InvalidateAllCache();
await ReloadAllData();
}
private async Task ReloadAllData()
{
isLoading = true;
await Task.Delay(1);
//AllRecords = null;
SearchRecords = await DataService.InstallazioniGLSGetAll();
totalCount = SearchRecords.Count();
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#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 PagerReloadNum(int newNum)
{
numRecord = newNum;
await ReloadAllData();
isLoading = false;
}
protected async Task PagerReloadPage(int newNum)
{
currPage = newNum;
await ReloadAllData();
isLoading = false;
}
protected async Task ResetData()
{
await fullReload();
}
protected async Task UpdateData()
{
await fullReload();
}
#endregion Protected Methods
#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
}
}