Files
Mapo-IOB/SMGen/Components/FamIngList.razor.cs
2023-08-10 11:09:35 +02:00

84 lines
2.4 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 SMGen;
using SMGen.Shared;
using SMGen.Components;
using EgwCoreLib.Razor;
using EgwCoreLib.Razor.Data;
using SMGen.Data;
using SMGen.Core;
using SMGen.Data.DbModels;
using SMGen.Data.Controllers;
using SMGen.Data.Services;
namespace SMGen.Components
{
public partial class FamIngList
{
protected List<FamIngressiViewModel> FamIngs = new List<FamIngressiViewModel>();
protected List<FamIngressiViewModel> SearchRecords = new List<FamIngressiViewModel>();
[Parameter]
public SelectFamIngParams currFilter { get; set; } = null!;
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
[Inject]
protected SMGDataService SMGDService{ get; set; } = null!;
private int _totalCount { get; set; } = 0;
private int currPage
{
get => currFilter.CurrPage;
set => currFilter.CurrPage = value;
}
private int numRecord
{
get => currFilter.NumRec;
set => currFilter.NumRec = value;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
protected override async Task OnParametersSetAsync()
{
await Task.Delay(1);
await ReloadData();
}
protected async Task ReloadData()
{
SearchRecords = await SMGDService.FamIngressiGetAll();
totalCount = SearchRecords.Count;
FamIngs = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await InvokeAsync(() => StateHasChanged());
}
}
}