82 lines
1.9 KiB
C#
82 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Core.DTO;
|
|
using MP.IOC.Services;
|
|
|
|
namespace MP.IOC.Components.Pages
|
|
{
|
|
public partial class RouteConf
|
|
{
|
|
#region Protected Methods
|
|
|
|
protected string CheckSelect(WeightDTO currRec)
|
|
{
|
|
return SelRecord != null && SelRecord.Method == currRec.Method ? "table-info" : "";
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
//return base.OnInitializedAsync();
|
|
await ReloadData();
|
|
UpdateTable();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<WeightDTO> ListComplete = new();
|
|
|
|
private List<WeightDTO> ListPaged = new();
|
|
|
|
private int numRecPage = 10;
|
|
|
|
private int pageNum = 1;
|
|
|
|
private WeightDTO? SelRecord = null;
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IWeightProvider WService { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ListComplete = await WService.GetAllWeightsAsync();
|
|
totalCount = ListComplete.Count();
|
|
}
|
|
|
|
private void SaveNumRec(int newNum)
|
|
{
|
|
numRecPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void SavePage(int newNum)
|
|
{
|
|
pageNum = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void UpdateTable()
|
|
{
|
|
// esegue paginazione
|
|
if (totalCount > numRecPage)
|
|
{
|
|
ListPaged = ListComplete.Skip((pageNum - 1) * numRecPage).Take(numRecPage).ToList();
|
|
}
|
|
else
|
|
{
|
|
ListPaged = ListComplete;
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |