Move some Utils functions to AppDbContext
This commit is contained in:
@ -86,27 +86,5 @@ namespace Elwig.Helpers {
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
|
||||
public static async Task<bool> MgNrExists(AppDbContext ctx, int mgnr) {
|
||||
return await ctx.Members.FindAsync(mgnr) != null;
|
||||
}
|
||||
|
||||
public static async Task<bool> VNrExists(AppDbContext ctx, int vnr) {
|
||||
return await ctx.Contracts.FindAsync(vnr) != null;
|
||||
}
|
||||
|
||||
public static async Task<int> NextMgNr(AppDbContext ctx) {
|
||||
int c = await ctx.Members.Select(m => m.MgNr).MinAsync();
|
||||
(await ctx.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
|
||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||
return c + 1;
|
||||
}
|
||||
|
||||
public static async Task<int> NextVNr(AppDbContext ctx) {
|
||||
int c = await ctx.Contracts.Select(co => co.VNr).MinAsync();
|
||||
(await ctx.Contracts.OrderBy(co => co.VNr).Select(co => co.VNr).ToListAsync())
|
||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||
return c + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user