Files
gpw_next/GPW.CORE.UI/Pages/Test.razor.cs
T
2022-01-26 14:38:18 +01:00

167 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using GPW.CORE.UI;
using GPW.CORE.UI.Shared;
using GPW.CORE.UI.Components;
using GPW.CORE.Data.DbModels;
using GPW.CORE.UI.Data;
namespace GPW.CORE.UI.Pages
{
public partial class Test : ComponentBase, IDisposable
{
#region Private Fields
private List<AnagFasiModel> ListRecords = null!;
private List<AnagFasiModel> 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 IdxDipSel = 0;
[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 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;
}
}
protected List<chartJsData.chartJsTSerie> getTsData()
{
List<chartJsData.chartJsTSerie> answ = new List<chartJsData.chartJsTSerie>();
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;
}
#endregion Protected 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
#region Protected Methods
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected void ResetData()
{
//DataService.rollBackEdit(currRecord);
}
protected void Select(DipendentiModel selRecord)
{
IdxDipSel = selRecord.IdxDipendente;
//// rimando a remnants
//NavManager.NavigateTo($"Remnants");
}
#endregion Protected Methods
#region Public Methods
public void Dispose()
{
//AppMService.EA_SearchUpdated -= OnSeachUpdated;
}
#endregion Public Methods
}
}