// Check if the EGN is valid private static string IsValid(long input) { long lastNumber = input % 10; long numbersToCheck = input / 10; var arr = digitArr(numbersToCheck); var arrsResult = controlNumberCalculation(arr); var divideByEleven = (long)arrsResult / 11; var controlNumber = (long)arrsResult - divideByEleven * 11; if (controlNumber >= 10) { controlNumber = 0; } if (controlNumber == lastNumber) { return(ValidationService.validEgn()); } else { return(ErrorService.invalidEgnError()); } }
private static string egnAuthorization(string egn) { long input; bool validInput = long.TryParse(egn, out input); if (input != 0) { var inputArray = digitArr(input); if (inputArray.Length < 10) { return(ErrorService.lessThanTenDigitsError()); } if (inputArray.Length > 10) { return(ErrorService.moreThanTenDigitsError()); } } else { return(ErrorService.invalidInputError()); } return(IsValid(input)); }