Fix bug where it is not possible to create new members
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ namespace WGneu.Helpers {
|
||||
return new(true, "Not implemented yet");
|
||||
}
|
||||
|
||||
public static ValidationResult CheckMgNr(TextBox input, bool optional, AppDbContext ctx, Member m) {
|
||||
public static ValidationResult CheckMgNr(TextBox input, bool optional, AppDbContext ctx, Member? m) {
|
||||
var res = CheckNumeric(input, optional);
|
||||
if (!res.IsValid) {
|
||||
return res;
|
||||
@ -264,7 +264,7 @@ namespace WGneu.Helpers {
|
||||
}
|
||||
|
||||
int nr = int.Parse(input.Text);
|
||||
if (nr != m.MgNr && Utils.MgNrExists(ctx, nr)) {
|
||||
if (nr != m?.MgNr && Utils.MgNrExists(ctx, nr)) {
|
||||
return new(false, "Mitgliedsnummer wird bereits verwendet");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user