From c3916dcf4165685a9a51fef722f8b137fa679bec Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 15 Jun 2023 12:58:47 +0200 Subject: [PATCH] Aggiunta metodo filtro periodo progetti --- .../Controllers/ProjController.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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)