public ActionResult Index(MRZDataCaptureModel mrzDataCaptureModel) { string dateOfBirthYYMMDD = string.Empty; string dateOfExpiryYYMMDD = string.Empty; // addition validation to standard model validation // validate dates are valid if (!IsDateValid(mrzDataCaptureModel.DateOfBirth, out dateOfBirthYYMMDD)) { ModelState.AddModelError("DateOfBirth", "Error in date"); } if (!IsDateValid(mrzDataCaptureModel.DateOfExpiry, out dateOfExpiryYYMMDD)) { ModelState.AddModelError("DateOfExpiry", "Error in date"); } if (ModelState.IsValid) { var res = validate.ValidateMRZ(mrzDataCaptureModel.MRZ, mrzDataCaptureModel.PassportNumber, mrzDataCaptureModel.Nationality, dateOfBirthYYMMDD, mrzDataCaptureModel.Gender, dateOfExpiryYYMMDD, mrzDataCaptureModel.PersonalNumber); ValidateMRZResultModel validateMRZResultModel = new ValidateMRZResultModel(); validateMRZResultModel.IsPersonalNumberCheckDigitValid = res.IsPersonalNumberCheckDigitValid; validateMRZResultModel.IsDateOfBirthCheckDigitValid = res.IsDateOfBirthCheckDigitValid; validateMRZResultModel.IsDateOfBirthCrossCheckValid = res.IsDateOfBirthCrossCheckValid; validateMRZResultModel.IsDateOfExpiryCheckDigitValid = res.IsDateOfExpiryCheckDigitValid; validateMRZResultModel.IsDateOfExpiryCrossCheckValid = res.IsDateOfExpiryCrossCheckValid; validateMRZResultModel.IsFinalCheckDigitValid = res.IsFinalCheckDigitValid; validateMRZResultModel.IsGenderCrossCheckValid = res.IsGenderCrossCheckValid; validateMRZResultModel.IsNationalitCrossCheckValid = res.IsNationalitCrossCheckValid; validateMRZResultModel.IsPassportNumberCheckDigitValid = res.IsPassportNumberCheckDigitValid; validateMRZResultModel.IsPassportNumberCrossCheckValid = res.IsPassportNumberCrossCheckValid; validateMRZResultModel.IsPersonalNumberCrossCheckValid = res.IsPersonalNumberCrossCheckValid; validateMRZResultModel.IsServiceAvailable = res.IsServiceAvailable; return(View("Results", validateMRZResultModel)); } // Error occurred in data form // Becasue ValidateInput=false encode values before displaying mrzDataCaptureModel.PassportNumber = HttpUtility.HtmlEncode(mrzDataCaptureModel.PassportNumber); mrzDataCaptureModel.Nationality = HttpUtility.HtmlEncode(mrzDataCaptureModel.Nationality); mrzDataCaptureModel.DateOfBirth = HttpUtility.HtmlEncode(mrzDataCaptureModel.DateOfBirth); mrzDataCaptureModel.Gender = mrzDataCaptureModel.Gender; mrzDataCaptureModel.GenderItems = GetGenders(); mrzDataCaptureModel.DateOfExpiry = HttpUtility.HtmlEncode(mrzDataCaptureModel.DateOfExpiry); mrzDataCaptureModel.MRZ = HttpUtility.HtmlEncode(mrzDataCaptureModel.MRZ); return(View(mrzDataCaptureModel)); }
public ActionResult Index() { MRZDataCaptureModel mrzDataCaptureModel = new MRZDataCaptureModel(); /* * // preload with test data for initial testing * MRZDataCaptureModel mrzDataCaptureModel = new MRZDataCaptureModel * { * MRZ = "9991263238GBR9102033M2302281<<<<<<<<<<<<<<02", * PassportNumber = "999126323", * Nationality = "GBR", * DateOfBirth = "03/02/1991", * Gender = "M", * DateOfExpiry = "28/02/2023", * PersonalNumber = "<<<<<<<<<<<<<<" * }; */ mrzDataCaptureModel.GenderItems = GetGenders(); return(View(mrzDataCaptureModel)); }