using MP.MONO.Data.DbModels; namespace MP.MONO.UI.Components { public partial class PrevMaintTask { #region Protected Methods protected override async Task OnInitializedAsync() { await ReloadData(); } #endregion Protected Methods #region Private Fields private int _MaxRecord = 200; private bool doSetup = false; private List? ListRecords = null; // FARE!!! filtro macchina private int MachineId = 1; private List? SearchRecords = null; #endregion Private Fields #region Private Properties private int _currPage { get; set; } = 1; private int _numRecord { get; set; } = 10; private int currPage { get => _currPage; set { if (_currPage != value) { _currPage = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private bool isLoading { get; set; } = false; private int MaxRecord { get { return _MaxRecord; } set { if (_MaxRecord != value) { _MaxRecord = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private int numRecord { get => _numRecord; set { if (_numRecord != value) { _numRecord = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private int totalCount { get { int answ = 0; if (SearchRecords != null) { answ = SearchRecords.Count; } return answ; } } #endregion Private Properties #region Private Methods private void ForceReload(int newNum) { numRecord = newNum; } private void ForceReloadPage(int newNum) { currPage = newNum; } private async Task ReloadData() { isLoading = true; ListRecords = null; await Task.Delay(1); SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); await Task.Delay(1); isLoading = false; } #endregion Private Methods } }