using EgwCoreLib.Razor.Data; using GPW.CORE.Data.DbModels; using GPW.CORE.Data.Services; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; namespace GPW.CORE.WRKLOG.Components.Pages { public partial class Test : ComponentBase, IDisposable { #region Public Methods public void Dispose() { //AppMService.EA_SearchUpdated -= OnSeachUpdated; } #endregion Public Methods #region Protected Properties [Inject] protected MessageService AppMService { get; set; } = null!; [Inject] protected GpwDataService DataService { get; set; } = null!; [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; protected int totalCount { get { int answ = 0; if (SearchRecords != null) { answ = SearchRecords.Count; } return answ; } } #endregion Protected Properties #region Protected Methods protected void ForceReload(int newNum) { numRecord = newNum; } protected void ForceReloadPage(int newNum) { currPage = newNum; } protected List getTsData() { List answ = new List(); DateTime dtCurs = DateTime.Now.AddDays(-120); Random rnd = new Random(); for (int i = 0; i < 60; i++) { answ.Add(new chartJsData.chartJsTSerie() { x = dtCurs, y = (decimal)(360 + rnd.Next(-5, 12)) / 10 }); dtCurs = dtCurs.AddDays(rnd.Next(1, 4)); } return answ; } protected override async Task OnInitializedAsync() { await ReloadData(); } protected void ResetData() { //GDataServ.rollBackEdit(CurrRecord); } protected void Select(DipendentiModel selRecord) { IdxDipSel = selRecord.IdxDipendente; //// rimando a remnants //NavManager.NavigateTo($"Remnants"); } #endregion Protected Methods #region Private Fields private int IdxDipSel = 0; private List ListRecords = null!; 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; [Inject] private NavigationManager NavManager { get; set; } = null!; private int numRecord { get => _numRecord; set { if (_numRecord != value) { _numRecord = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } #endregion Private Properties #region Private Methods private async Task ReloadData() { isLoading = true; SearchRecords = await DataService.AnagFasiAll(); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); isLoading = false; } #endregion Private Methods } }