Files
mapo-core/MP.INVE/Components/ListTotLotto.razor.cs
T
Samuele Locatelli f016d8dbd7 INVE:
- Completato aggiunta search x lotti anche testo parziale
- fix paginazione (non c'era)
2022-12-17 09:46:53 +01:00

134 lines
3.3 KiB
C#

using Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.INVE.Data;
namespace MP.INVE.Components
{
public partial class ListTotLotto
{
#region Public Properties
[Parameter]
public SelectInvioParams currParams { get; set; } = null!;
[Parameter]
public bool isLoading { get; set; }
[Parameter]
public string searchVal { get; set; } = "";
[Parameter]
public int SessionID { get; set; } = 0;
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
#endregion Public Properties
#region Public Methods
public void Dispose()
{
elencoTotLotto = null;
SearchRecords = null;
GC.Collect();
}
#endregion Public Methods
#region Protected Fields
protected List<InveSessTotLotModel>? elencoTotLotto;
#endregion Protected Fields
#region Protected Properties
[Inject]
protected MiDataService MIService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
await Task.Delay(1);
if (SessionID != 0)
{
await reloadData();
}
}
#endregion Protected Methods
#region Private Fields
private List<InveSessTotLotModel>? SearchRecords;
#endregion Private Fields
#region Private Properties
private int _totalCount { get; set; } = 0;
private int currPage
{
get => currParams.CurrPage;
set
{
currParams.CurrPage = value;
StateHasChanged();
}
}
private int numRecord
{
get => currParams.NumRec;
set
{
currParams.NumRec = value;
StateHasChanged();
}
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
#endregion Private Properties
#region Private Methods
private async Task reloadData()
{
elencoTotLotto = null;
//totalCount = 0;
isLoading = true;
SearchRecords = MIService.InveSessTotLotList(SessionID);
// se ho search --> filtro...
if (!string.IsNullOrEmpty(searchVal))
{
StringComparison strComp = StringComparison.CurrentCultureIgnoreCase;
SearchRecords = SearchRecords.Where(x => x.CodArticolo.Contains(searchVal, strComp) || x.DescrArt.Contains(searchVal, strComp) || x.Lotto.Contains(searchVal, strComp)).ToList();
}
totalCount = SearchRecords.Count;
elencoTotLotto = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
await Task.Delay(1);
isLoading = false;
}
#endregion Private Methods
}
}