diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs index cff3d240..0c998765 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs @@ -2,6 +2,7 @@ using NLog; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using static EgtBEAMWALL.Core.ConstBeam; @@ -328,6 +329,37 @@ namespace EgtBEAMWALL.DataLayer.Controllers } return answ; } + /// + /// Elenco progetti + /// + /// Inizio periodo estrazione + /// Fine periodo estrazione + /// Num max record da recuperare + /// Solo i record attivi (senza cancellazione logica) + /// + public List GetLastDesc(DateTime dtStart, DateTime dtEnd, int numRecord, bool OnlyActive) + { + List answ = new List(); + + using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING)) + { + // se numRecord = 0 --> passo tutti + if (numRecord == 0) + { + numRecord = localDbCtx.ProjList.Count(); + } + // retrieve + var dbRes = localDbCtx + .ProjList + .Where(x => (x.DtCreated >= dtStart && x.DtCreated <= dtEnd) && (!OnlyActive || x.IsActive)) + .OrderByDescending(x => x.ProjId) + .Take(numRecord) + .ToList(); + // conversione + answ = dbRes.Select(x => coreConv(x)).ToList(); + } + return answ; + } /// /// Fornisce nuovo indice VUOTO da usare (allocando sul DB)