Files
gpw_next/GPW.CORE.UI/Components/FasiSearch.razor.cs
T
2022-01-26 14:38:18 +01:00

115 lines
2.8 KiB
C#

using GPW.CORE.Data.DbModels;
using GPW.CORE.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.UI.Components
{
public partial class FasiSearch
{
#region Protected Fields
protected string _gruppoSel = "";
protected int _idxProj = 0;
protected bool vetoUpd = false;
#endregion Protected Fields
#region Public Fields
public int idxFase = 0;
#endregion Public Fields
#region Private Properties
[Inject]
private MessageService AppMServ { get; set; }
[Inject]
private IJSRuntime JSRuntime { get; set; }
#endregion Private Properties
#region Protected Properties
protected List<AnagFasiModel> fasiList { get; set; } = new List<AnagFasiModel>();
[Inject]
protected GpwDataService GDataServ { get; set; }
protected List<AnagGruppiModel> gruppiList { get; set; } = new List<AnagGruppiModel>();
protected List<AnagProgettiModel> projList { get; set; } = new List<AnagProgettiModel>();
#endregion Protected Properties
#region Public Properties
public string gruppoSel
{
get
{
return _gruppoSel;
}
set
{
_gruppoSel = value;
if (!vetoUpd)
{
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
public int idxProj
{
get
{
return _idxProj;
}
set
{
_idxProj = value;
if (!vetoUpd)
{
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Parameter]
public EventCallback<int> ItemSelected { get; set; }
#endregion Public Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
gruppiList = await GDataServ.AnagGruppiAll();
var allProj = await GDataServ.AnagProjAll();
projList = allProj.Where(x => x.Attivo == true && x.Gruppo == gruppoSel).OrderBy(x => x.ClienteNav.RagSociale).ThenBy(x => x.NomeProj).ToList();
var allFasi = await GDataServ.AnagFasiAll();
fasiList = allFasi.Where(x => x.IdxProgetto == idxProj && x.Attivo == true).ToList();
}
protected async Task SelectRecord()
{
await ItemSelected.InvokeAsync(idxFase);
}
#endregion Protected Methods
}
}