diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index f8899e5..8bb08f8 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -248,6 +248,38 @@ namespace GPW.CORE.Data.Controllers return answ; } + public bool RegAttUpdate(RegAttivitaModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetRegAttivita + .FirstOrDefault(x => x.IdxRa == currItem.IdxRa); + if (currRec != null) + { + currRec.IdxDipendente = currItem.IdxDipendente; + currRec.IdxFase = currItem.IdxFase; + currRec.Inizio = currItem.Inizio; + currRec.Fine = currItem.Fine; + currRec.Descrizione = currItem.Descrizione; + + localDbCtx.DbSetRegAttivita.Update(currRec); + localDbCtx.SaveChanges(); + + answ = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegAttUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + /// /// Recupera overview di un periodo settimanale x dipendente, data riferimento, numero settimane precedenti /// diff --git a/GPW.CORE.UI/Components/RegAttEditor.razor b/GPW.CORE.UI/Components/RegAttEditor.razor index f0849c4..3ed2276 100644 --- a/GPW.CORE.UI/Components/RegAttEditor.razor +++ b/GPW.CORE.UI/Components/RegAttEditor.razor @@ -22,12 +22,6 @@ } - @* - @foreach (var item in clientiList) - { - - } - *@ @@ -39,26 +33,28 @@
-
+ +
- +
- + @foreach (var item in projList) { }
-
+ +
- +
- + @foreach (var item in fasiList) { if (@item.EnableTime) @@ -74,6 +70,7 @@
+
@@ -109,6 +106,7 @@
*@ +
@@ -122,14 +120,20 @@
+
+ +
- +
+
+
-
+
+
diff --git a/GPW.CORE.UI/Components/RegAttEditor.razor.cs b/GPW.CORE.UI/Components/RegAttEditor.razor.cs index 4cbb011..d268fab 100644 --- a/GPW.CORE.UI/Components/RegAttEditor.razor.cs +++ b/GPW.CORE.UI/Components/RegAttEditor.razor.cs @@ -26,7 +26,10 @@ namespace GPW.CORE.UI.Components protected RegAttivitaModel selRecord { get; set; } = null; + protected bool vetoUpd = false; + protected string _gruppoSel = ""; + protected int _idxProj = 0; public string gruppoSel { @@ -37,8 +40,28 @@ namespace GPW.CORE.UI.Components set { _gruppoSel = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); + 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(); + } } } @@ -52,20 +75,23 @@ namespace GPW.CORE.UI.Components set { selRecord = value; + vetoUpd = true; if (value.FasiNav != null && value.FasiNav.ProgettoNav != null) { gruppoSel = value.FasiNav.ProgettoNav.Gruppo; + idxProj = value.FasiNav.IdxProgetto != null ? (int)value.FasiNav.IdxProgetto : 0; } - else - { - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + vetoUpd = false; + } } [Parameter] public EventCallback ItemReset { get; set; } + [Parameter] + public EventCallback ItemUpdated { get; set; } [Inject] protected GpwDataService GDataServ { get; set; } @@ -81,7 +107,7 @@ namespace GPW.CORE.UI.Components .ToList(); var allFasi = await GDataServ.AnagFasiAll(); fasiList = allFasi - .Where(x => x.IdxProgetto == currRecord.FasiNav.IdxProgetto) + .Where(x => x.IdxProgetto == idxProj) .ToList(); } @@ -92,5 +118,15 @@ namespace GPW.CORE.UI.Components { await ItemReset.InvokeAsync(true); } + /// + /// Indico item selezionato + /// + protected async void DoUpdate() + { + // aggiorno + await GDataServ.RegAttUpdate(currRecord); + // registro fatto + await ItemUpdated.InvokeAsync(true); + } } } \ No newline at end of file diff --git a/GPW.CORE.UI/Data/GpwDataService.cs b/GPW.CORE.UI/Data/GpwDataService.cs index 4160408..e6234df 100644 --- a/GPW.CORE.UI/Data/GpwDataService.cs +++ b/GPW.CORE.UI/Data/GpwDataService.cs @@ -388,6 +388,20 @@ namespace GPW.CORE.UI.Data return await Task.FromResult(dbResult); } + public async Task RegAttUpdate(RegAttivitaModel currItem) + { + bool answ = false; + try + { + dbController.RegAttUpdate(currItem); + // invalido la cache... + await InvalidateAllCache(); + answ = true; + } + catch + { } + return answ; + } #if false public async Task> MaterialsGetAll() { diff --git a/GPW.CORE.UI/Pages/Planner.razor b/GPW.CORE.UI/Pages/Planner.razor index ce2e438..17ca6c5 100644 --- a/GPW.CORE.UI/Pages/Planner.razor +++ b/GPW.CORE.UI/Pages/Planner.razor @@ -39,7 +39,7 @@ @if (currRecord != null) { - + } @if (ListRecords == null) {