- update in cascata x archived (prod --> proj)

- filtro archived x proj
This commit is contained in:
Samuele Locatelli
2023-08-25 11:01:27 +02:00
parent 7bc58a74e1
commit 34089f946f
2 changed files with 20 additions and 7 deletions
@@ -66,7 +66,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
public bool DeleteProd(int ProdId, bool IsLogical)
{
bool done = false;
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
var currProd = localDbCtx
@@ -545,11 +544,22 @@ namespace EgtBEAMWALL.DataLayer.Controllers
.SingleOrDefault();
if (currData != null)
{
// sel dei proj da aggiornare...
var proj2update = localDbCtx
.ProjList
.Where(x => x.ProdDbId == currData.ProdDbId)
.ToList();
try
{
// aggiorno valore descrizione
currData.IsArchived = IsArchived;
// update dei proj relativi
foreach (var item in proj2update)
{
item.IsArchived = IsArchived;
}
// Commit changes
localDbCtx.SaveChanges();
}
@@ -306,8 +306,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <param name="dtEnd">Fine periodo estrazione (per export date)</param>
/// <param name="numRecord">Num max record da recuperare</param>
/// <param name="OnlyActive">Solo i record attivi (senza cancellazione logica)</param>
/// <param name="ShowArchived">Se true: mostra anche archiviati (default li nasconde)</param>
/// <returns></returns>
public List<Core.ProjFileM> GetLastByExpDesc(DateTime dtStart, DateTime dtEnd, int numRecord, bool OnlyActive)
public List<Core.ProjFileM> GetLastByExpDesc(DateTime dtStart, DateTime dtEnd, int numRecord, bool OnlyActive, bool ShowArchived = false)
{
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
@@ -321,7 +322,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// retrieve
var dbRes = localDbCtx
.ProjList
.Where(x => (x.DtExported >= dtStart && x.DtExported <= dtEnd) && (!OnlyActive || x.IsActive))
.Where(x => (!x.IsArchived || ShowArchived) && (x.DtExported >= dtStart && x.DtExported <= dtEnd) && (!OnlyActive || x.IsActive))
.OrderByDescending(x => x.ProjId)
.Take(numRecord)
.ToList();
@@ -336,8 +337,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// </summary>
/// <param name="numRecord">Num max record da recuperare</param>
/// <param name="OnlyActive">Solo i record attivi (senza cancellazione logica)</param>
/// <param name="ShowArchived">Se true: mostra anche archiviati (default li nasconde)</param>
/// <returns></returns>
public List<Core.ProjFileM> GetLastDesc(int numRecord, bool OnlyActive)
public List<Core.ProjFileM> GetLastDesc(int numRecord, bool OnlyActive, bool ShowArchived = false)
{
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
@@ -351,7 +353,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// retrieve
var dbRes = localDbCtx
.ProjList
.Where(x => (!OnlyActive || x.IsActive))
.Where(x => (!x.IsArchived || ShowArchived) && (!OnlyActive || x.IsActive))
.OrderByDescending(x => x.ProjId)
.Take(numRecord)
.ToList();
@@ -368,8 +370,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <param name="dtEnd">Fine periodo estrazione</param>
/// <param name="numRecord">Num max record da recuperare</param>
/// <param name="OnlyActive">Solo i record attivi (senza cancellazione logica)</param>
/// <param name="ShowArchived">Se true: mostra anche archiviati (default li nasconde)</param>
/// <returns></returns>
public List<Core.ProjFileM> GetLastDesc(DateTime dtStart, DateTime dtEnd, int numRecord, bool OnlyActive)
public List<Core.ProjFileM> GetLastDesc(DateTime dtStart, DateTime dtEnd, int numRecord, bool OnlyActive, bool ShowArchived = false)
{
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
@@ -383,7 +386,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// retrieve
var dbRes = localDbCtx
.ProjList
.Where(x => (x.DtCreated >= dtStart && x.DtCreated <= dtEnd) && (!OnlyActive || x.IsActive))
.Where(x => (!x.IsArchived || ShowArchived) && (x.DtCreated >= dtStart && x.DtCreated <= dtEnd) && (!OnlyActive || x.IsActive))
.OrderByDescending(x => x.ProjId)
.Take(numRecord)
.ToList();