Files
egwcorelib/EgwCoreLib.BlazorTest/Pages/FetchData.razor.cs
T
2023-05-09 10:45:23 +02:00

70 lines
1.8 KiB
C#

using EgwCoreLib.BlazorTest.Data;
using EgwCoreLib.Razor;
namespace EgwCoreLib.BlazorTest.Pages
{
public partial class FetchData
{
#region Protected Properties
protected List<int> PageSizeEnab { get; set; } = new List<int>();
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
PageSizeEnab = new List<int>()
{
4,8,12,16,20,24,28,32,36,40
};
await ReloadAllData();
}
protected async Task ReloadAllData()
{
var rawData = await ForecastService.GetForecastAsync(DateTime.Now);
totalCount = rawData.Count();
forecasts = rawData.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
}
protected async Task SetCurrPage(int newNum)
{
currPage = newNum;
await ReloadAllData();
}
protected async Task SetNumRec(int newNum)
{
numRecord = newNum;
await ReloadAllData();
}
protected async Task SortRequested(Sorter.SortCallBack e)
{
sortField = e.ParamName;
sortAsc = e.IsAscending;
await ReloadAllData();
}
#endregion Protected Methods
#region Private Fields
private List<WeatherForecast>? forecasts;
private bool sortAsc = true;
private string sortField = "";
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 8;
private int totalCount { get; set; } = 0;
#endregion Private Properties
}
}