diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs index b38e869..6f78d44 100644 --- a/LiMan.DB/Controllers/DbController.cs +++ b/LiMan.DB/Controllers/DbController.cs @@ -176,6 +176,32 @@ namespace LiMan.DB.Controllers return answ; } + public bool AttivazioniUnlock(int idxSubLic) + { + bool fatto = false; + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + DateTime oggi = DateTime.Today; + + // recupero record + var currData = localDbCtx + .DbSetSubLicenze + .Where(x => x.IdxSubLic == idxSubLic && x.VetoUnlock > oggi) + .FirstOrDefault(); + // se ho qualcosa procedo... + if (currData != null) + { + currData.VetoUnlock = oggi; + localDbCtx.Entry(currData).State = EntityState.Modified; + // salvo + localDbCtx.SaveChanges(); + } + // comunque true se ci ha provato + fatto = true; + } + return fatto; + } + public bool DbForceMigrate() { bool answ = false; diff --git a/LiMan.UI/Components/Activations.razor b/LiMan.UI/Components/Activations.razor index d40ad29..5a1f407 100644 --- a/LiMan.UI/Components/Activations.razor +++ b/LiMan.UI/Components/Activations.razor @@ -15,18 +15,9 @@ { - @if (currRecord == null) - { - - } - else - { - - } + @record.IdxSubLic diff --git a/LiMan.UI/Components/Activations.razor.cs b/LiMan.UI/Components/Activations.razor.cs index bb34a32..495bd67 100644 --- a/LiMan.UI/Components/Activations.razor.cs +++ b/LiMan.UI/Components/Activations.razor.cs @@ -1,6 +1,7 @@ using LiMan.DB.DBModels; using LiMan.UI.Data; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using System; using System.Collections.Generic; using System.Linq; @@ -42,6 +43,9 @@ namespace LiMan.UI.Components private bool isLoading { get; set; } = false; + [Inject] + private IJSRuntime JSRuntime { get; set; } + #endregion Private Properties #region Protected Properties @@ -119,18 +123,6 @@ namespace LiMan.UI.Components return answ; } - protected void Edit(SubLicenzaModel selRecord) - { - currRecord = selRecord; - } - -#if false - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } -#endif - protected async Task PagerReloadNum(int newNum) { numRecord = newNum; @@ -150,6 +142,16 @@ namespace LiMan.UI.Components await fullReload(); } + protected async Task UnLock(SubLicenzaModel selRecord) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il blocco? la data di scadenza verrà impostata a ieri liberando la licenza per cancellazioni o rimozioni.")) + return; + + // chiamo procedura sblocco... + DataService.AttivazioneUnlock(selRecord.IdxSubLic); + await ResetData(); + } + #endregion Protected Methods #region Public Methods diff --git a/LiMan.UI/Data/LiManDataService.cs b/LiMan.UI/Data/LiManDataService.cs index a77c9d7..2c66bd5 100644 --- a/LiMan.UI/Data/LiManDataService.cs +++ b/LiMan.UI/Data/LiManDataService.cs @@ -98,6 +98,22 @@ namespace LiMan.UI.Data #endregion Protected Methods + #region Internal Methods + + /// + /// Effettua sblocco di una licenza impostando data veto a oggi + /// + /// + /// + internal bool AttivazioneUnlock(int idxSubLic) + { + bool fatto = false; + dbControllerNext.AttivazioniUnlock(idxSubLic); + return fatto; + } + + #endregion Internal Methods + #region Public Methods ///