Files

86 lines
2.6 KiB
C#

using GPW.CORE.Data.DbModels;
using GPW.CORE.Data.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.ADM.Components.Compo
{
public partial class ProgettiDetail
{
#region Public Properties
[Parameter]
public CalcOreProgettiModel? CurrRecord { get; set; } = null;
[Parameter]
public EventCallback<bool> EC_update { get; set; }
#endregion Public Properties
#region Protected Properties
[Inject]
protected GpwDataService GDataServ { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task DoUpdate()
{
await GDataServ.AnagProjUpdStatus(CurrRecord.IdxProgetto, CurrRecord.Attivo ?? true, CurrRecord.Starred ?? false);
}
protected override void OnParametersSet()
{
NewProjName = CurrRecord.NomeProj;
DoYearSubst = true;
}
protected async Task DoClone()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler procedere con la clonazione del progetto(+fasi) selezionato?"))
return;
// verifico se il gruppo sia attivo, se non lo fosse avvisa che andrà cambiato...
var listGroup = await GDataServ.AnagGruppiAll();
if (listGroup != null)
{
var currRec = listGroup.FirstOrDefault(x => x.Gruppo == CurrRecord.Gruppo);
if (currRec != null && !(currRec.IsActive??false))
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Attenzione! l record è associato ad un gruppo disattivo, ricordati di cambiarlo dopo la modifica. Confermi di voler procedere?"))
return;
}
}
bool fatto = false;
await Task.Delay(1);
if (CurrRecord != null)
{
fatto = await GDataServ.AnagProjDoClone(CurrRecord.IdxProgetto, NewProjName, DoYearSubst);
// se fatto ricalcolo...
if (fatto)
{
await GDataServ.AnagProjForceUpdate();
}
}
await EC_update.InvokeAsync(fatto);
}
private string NewProjName = "";
private bool DoYearSubst = true;
protected async Task DoCancel()
{
await EC_update.InvokeAsync(true);
}
#endregion Protected Methods
}
}