From e939a4b5bfd3908e7ea20a4bacec18c08d7ae15a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 18 Nov 2021 18:48:18 +0100 Subject: [PATCH] Aggiunta metodi recupero remnants --- REMAN/NKC.Data/Controllers/NKCController.cs | 27 +++++++++++++++++++++ REMAN/NKC.Data/DbModels/RemnantsModel.cs | 8 +++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/REMAN/NKC.Data/Controllers/NKCController.cs b/REMAN/NKC.Data/Controllers/NKCController.cs index db30b53..863198f 100644 --- a/REMAN/NKC.Data/Controllers/NKCController.cs +++ b/REMAN/NKC.Data/Controllers/NKCController.cs @@ -37,6 +37,33 @@ namespace NKC.Data.Controllers return dbResult; } + + public List RemnantsGetAll() + { + List dbResult = new List(); + using (NKCContext localDbCtx = new NKCContext(_configuration)) + { + dbResult = localDbCtx + .DbSetRemnants + .ToList(); + } + return dbResult; + } + + public List RemnantsGetFilt(int matId, int minQty) + { + List dbResult = new List(); + using (NKCContext localDbCtx = new NKCContext(_configuration)) + { + dbResult = localDbCtx + .DbSetRemnants + .Where(x => (x.MatID == matId || matId == 0) && (x.QtyAvail >= minQty || minQty == 0)) + .OrderBy(o => o.Area) + .ToList(); + } + return dbResult; + } + public bool DbForceMigrate() { bool answ = false; diff --git a/REMAN/NKC.Data/DbModels/RemnantsModel.cs b/REMAN/NKC.Data/DbModels/RemnantsModel.cs index bc377c6..6e567b0 100644 --- a/REMAN/NKC.Data/DbModels/RemnantsModel.cs +++ b/REMAN/NKC.Data/DbModels/RemnantsModel.cs @@ -56,7 +56,13 @@ namespace NKC.Data.DbModels /// Note (optional) /// public string Note { get; set; } = ""; - + + [NotMapped] + public decimal Area + { + get => LMm * WMm; + } + /// /// Navigation property to Material ///