b072312a71
- ok gestione gruppi - update spostamento fasi
183 lines
5.3 KiB
C#
183 lines
5.3 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using NLog;
|
|
|
|
namespace GPW.CORE.ADM.Components.Compo
|
|
{
|
|
public partial class Dip2GrpMan : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public string CodGruppo { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
AppMServ.EA_SearchUpdated -= AppMServ_EA_SearchUpdated;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected GpwDataService GDataServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string CheckItem(DipendentiModel currItem)
|
|
{
|
|
string answ = !(currItem.Attivo ?? false) ? "striked" : "";
|
|
return answ;
|
|
}
|
|
|
|
protected async void DoDelete(DipendentiModel selItem)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler rimuovere il record di associazione dipendente/gruppo?"))
|
|
return;
|
|
|
|
isLoading = true;
|
|
|
|
await GDataServ.Dipendenti2GrpDelete(selItem.IdxDipendente, CodGruppo);
|
|
await ReloadData();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
CurrSearch = "";
|
|
AppMServ.SearchVal = "";
|
|
AppMServ.EA_SearchUpdated += AppMServ_EA_SearchUpdated;
|
|
numRecord = await AppMServ.NumRowGridGet(gridKey);
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task SetNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
await AppMServ.NumRowGridSet(gridKey, newNum);
|
|
await InvokeAsync(ReloadData);
|
|
}
|
|
|
|
protected async Task SetPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
await InvokeAsync(ReloadData);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private string gridKey = "Dip2GrpMan";
|
|
|
|
private int idxDipSel = 0;
|
|
|
|
private bool showInactive = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage { get; set; } = 1;
|
|
|
|
private string CurrSearch { get; set; } = "";
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private List<DipendentiModel> ListDipendenti { get; set; } = new List<DipendentiModel>();
|
|
|
|
private List<DipendentiModel>? ListRecords { get; set; } = null;
|
|
|
|
private int numRecord { get; set; } = 10;
|
|
|
|
private List<DipendentiModel>? SearchRecords { get; set; } = null;
|
|
|
|
private bool ShowInactive
|
|
{
|
|
get => showInactive;
|
|
set { showInactive = value; }
|
|
}
|
|
|
|
private int totalCount { get; set; } = 0;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async void AppMServ_EA_SearchUpdated()
|
|
{
|
|
CurrSearch = AppMServ.SearchVal;
|
|
await ReloadData();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
ListDipendenti = await GDataServ.DipendentiGetAll();
|
|
try
|
|
{
|
|
SearchRecords = await GDataServ.DipendentiByGrp(CodGruppo);
|
|
// tolgo da el associabili quelli già associati...
|
|
ListDipendenti = ListDipendenti.Where(i => !SearchRecords.Contains(i)).ToList();
|
|
// verifico filtro per ricerca
|
|
if (!string.IsNullOrEmpty(CurrSearch))
|
|
{
|
|
SearchRecords = SearchRecords.Where(x => x.Cognome.Contains(CurrSearch, StringComparison.InvariantCultureIgnoreCase) || x.Nome.Contains(CurrSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
|
}
|
|
if (!showInactive)
|
|
{
|
|
SearchRecords = SearchRecords.Where(x => x.Attivo ?? false).ToList();
|
|
ListDipendenti = ListDipendenti.Where(x => x.Attivo ?? false).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error($"Eccezione in recupero dati{Environment.NewLine}{ex}");
|
|
}
|
|
totalCount = SearchRecords.Count;
|
|
|
|
// filtro x display
|
|
ListRecords = SearchRecords
|
|
.OrderBy(x => x.Cognome)
|
|
.ThenBy(x => x.Nome)
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
|
|
// cerco i dip del gruppo...
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task AddSelected()
|
|
{
|
|
await GDataServ.Dipendenti2GrpInsert(idxDipSel, CodGruppo);
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |