Add VNr Utils functions
This commit is contained in:
@ -91,11 +91,22 @@ namespace Elwig.Helpers {
|
|||||||
return await ctx.Members.FindAsync(mgnr) != null;
|
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) {
|
public static async Task<int> NextMgNr(AppDbContext ctx) {
|
||||||
int c = await ctx.Members.Select(m => m.MgNr).MinAsync();
|
int c = await ctx.Members.Select(m => m.MgNr).MinAsync();
|
||||||
(await ctx.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
|
(await ctx.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
|
||||||
.ForEach(a => { if (a <= c + 100) c = a; });
|
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
return c + 1;
|
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