Files
NKC/REMAN/Components/MovMagDetail.razor.cs
2021-11-25 09:56:11 +01:00

153 lines
3.5 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using NKC.Data.DbModels;
using REMAN.Data;
namespace REMAN.Components
{
public partial class MovMagDetail
{
#region Private Fields
private int _maxRec = 100;
private List<MovMagModel> ListRecords = null!;
private List<MovMagModel> 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 maxRec
{
get
{
return _maxRec;
}
set
{
_maxRec = 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();
}
}
}
#endregion Private Properties
#region Protected Properties
protected int _remnId { get; set; } = 0;
[Inject]
protected RDataService 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 Public Properties
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public int RemnID
{
get
{
return _remnId;
}
set
{
_remnId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
#endregion Public Properties
#region Private Methods
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.MovMagGetFilt(RemnID, maxRec);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected async Task Close()
{
await DataReset.InvokeAsync(0);
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
#endregion Protected Methods
}
}