127 lines
3.9 KiB
C#
127 lines
3.9 KiB
C#
using Liman.CadCam.DbModel;
|
|
using Liman.CadCam.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class CadCamSearchLic
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<string> EC_LockIdSel { get; set; }
|
|
|
|
[Parameter]
|
|
public string LockId { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public int ProdId { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public string searchVal { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected CadCamService CCService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
ReloadAllData();
|
|
// aggiorno
|
|
}
|
|
|
|
protected async Task ReportLockId(string lockId)
|
|
{
|
|
await EC_LockIdSel.InvokeAsync(lockId);
|
|
}
|
|
|
|
protected void setNumPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
ReloadAllData();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void setNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
ReloadAllData();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private List<LicenceModel> AllRecords { get; set; } = new List<LicenceModel>();
|
|
|
|
private int currPage { get; set; } = 1;
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private List<LicenceModel> ListRecords { get; set; } = new List<LicenceModel>();
|
|
private int numRecord { get; set; } = 10;
|
|
private List<LicenceModel> SearchRecords { get; set; } = new List<LicenceModel>();
|
|
private int totalCount { get; set; } = 0;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void ReloadAllData()
|
|
{
|
|
// rileggo i dati
|
|
isLoading = true;
|
|
if (!string.IsNullOrEmpty(searchVal) || !string.IsNullOrEmpty(LockId))
|
|
{
|
|
SearchRecords = AllRecords
|
|
.Where(x => (ProdId == 0 || x.ProductID == ProdId) && (string.IsNullOrEmpty(LockId) || x.LockID.Contains(LockId, StringComparison.CurrentCultureIgnoreCase))
|
|
&& (string.IsNullOrEmpty(searchVal) || (
|
|
(!string.IsNullOrEmpty(x.Note) && x.Note.Contains(searchVal, StringComparison.CurrentCultureIgnoreCase))
|
|
|| x.ProductVersion.ToString().Contains(searchVal, StringComparison.CurrentCultureIgnoreCase)
|
|
|| (!string.IsNullOrEmpty(x.Note) && x.Note.Contains(searchVal, StringComparison.CurrentCultureIgnoreCase))
|
|
))
|
|
)
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = new List<LicenceModel>();
|
|
}
|
|
// ordinamento data desc
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.DtScadenza).ToList();
|
|
totalCount = SearchRecords.Count;
|
|
// paginazione!
|
|
ListRecords = SearchRecords
|
|
.Skip((currPage - 1) * numRecord)
|
|
.Take(numRecord)
|
|
.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
AllRecords = await CCService.LicencesGetAll();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |