diff --git a/Elwig/Helpers/Validator.cs b/Elwig/Helpers/Validator.cs index a192aff..efb37e9 100644 --- a/Elwig/Helpers/Validator.cs +++ b/Elwig/Helpers/Validator.cs @@ -295,5 +295,26 @@ namespace Elwig.Helpers { // TODO return new(true, "Not implemented yet"); } + + public static ValidationResult CheckVNr(TextBox input, bool required, AppDbContext ctx, Contract? c) { + var res = CheckNumeric(input, required); + if (!res.IsValid) { + return res; + } else if (!required && input.Text.Length == 0) { + return new(true, null); + } + + int nr = int.Parse(input.Text); + if (nr != c?.VNr && Utils.VNrExists(ctx, nr).GetAwaiter().GetResult()) { + return new(false, "Vertragsnummer wird bereits verwendet"); + } + + return new(true, null); + } + + public static ValidationResult CheckGstNr(TextBox input, bool required) { + // TODO + return new(true, "Not implemented yet"); + } } }