Fix bug where it is not possible to create new members

This commit is contained in:
2023-03-13 17:22:02 +01:00
parent 11744a3d87
commit a17210e93c
3 changed files with 34 additions and 20 deletions

View File

@ -65,5 +65,11 @@ namespace WGneu.Helpers {
public static bool MgNrExists(AppDbContext ctx, int mgnr) {
return ctx.Members.Find(mgnr) != null;
}
public static int NextMgNr(AppDbContext ctx) {
int c = ctx.Members.Select(m => m.MgNr).Min();
ctx.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToList().ForEach(a => { if (a <= c + 100) c = a; });
return c + 1;
}
}
}