Files
2024-09-10 18:33:49 +02:00

72 lines
1.9 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;
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
}
}