Advertisement
Maximvdw

Answer Submitted

Jun 2nd, 2015
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq;
  5. using System.Web;
  6.  
  7. namespace ExamenVoorbeeld.Models
  8. {
  9.     public class VluchtIDVerification : ValidationAttribute
  10.     {
  11.         public override bool IsValid(object value)
  12.         {
  13.             if (!(value is String))
  14.                 return false;
  15.             String val = value.ToString();
  16.  
  17.             if (string.IsNullOrWhiteSpace(val))
  18.                 return false;
  19.  
  20.             String[] dat = val.Split('/');
  21.             if (dat.Length != 3)
  22.                 return false;
  23.             int errorCode = -1;
  24.             if (!Int32.TryParse(dat[2],out errorCode))
  25.                 return false;
  26.             int valNumberBack = Int32.Parse(dat[2]);
  27.             if (!Int32.TryParse(dat[0], out errorCode))
  28.                 return false;
  29.             int valNumberFront = Int32.Parse(dat[0]);
  30.  
  31.             if (999 - valNumberFront == valNumberBack)
  32.                 return true;
  33.  
  34.             return false;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement