From 09a7889044f02df964665d9ffb9972db0b7ef518 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 8 Jan 2024 14:18:15 +0100 Subject: [PATCH] AppDbContext: Add NextAvNr() --- Elwig/Helpers/AppDbContext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Elwig/Helpers/AppDbContext.cs b/Elwig/Helpers/AppDbContext.cs index 30d9099..d3f9fdc 100644 --- a/Elwig/Helpers/AppDbContext.cs +++ b/Elwig/Helpers/AppDbContext.cs @@ -200,6 +200,13 @@ namespace Elwig.Helpers { return c + 1; } + public async Task NextAvNr(int year) { + int c = 0; + (await PaymentVariants.Where(v => v.Year == year).Select(v => v.AvNr).ToListAsync()) + .ForEach(a => { if (a <= c + 100) c = a; }); + return c + 1; + } + public async Task GetWineQualityLevel(double kmw) { return await WineQualityLevels .Where(q => !q.IsPredicate && (q.MinKmw == null || q.MinKmw <= kmw))