Beispiel #1
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {   //default value is today
     if (HereSince.Equals(null))
     {
         HereSince = DateTime.Now;
     }
     else if (HereSince.CompareTo(DateTime.Now) > 0)
     {
         yield return(new ValidationResult(
                          $"Dogs cannot check-in later than today.",
                          new[] { "HereSince" }));
     }
     //birth date can be unknown
     if (DateOfBirth.Equals(null))
     {
     }
     //birth date can't be later thay today
     if (DateOfBirth.CompareTo(DateTime.Now) > 0)
     {
         yield return(new ValidationResult(
                          $"birth date can't be later thay today.",
                          new[] { "DateOfBirth" }));
     }
     //Impossible for dog to be here faster then it's birth.
     if (DateOfBirth.CompareTo(HereSince) > 0)
     {
         yield return(new ValidationResult(
                          $"Impossible for dog to be here faster then it's birth.",
                          new[] { "HereSince", "DateOfBirth" }));
     }
 }
Beispiel #2
0
 public int CompareTo(object o)
 {
     if (o is Person person)
     {
         return(DateOfBirth.CompareTo(person.DateOfBirth));
     }
     throw new Exception("Невозможно сравнить два объекта");
 }
Beispiel #3
0
        public int CompareTo(object obj)
        {
            Student student = obj as Student;

            if (student != null)
            {
                return(DateOfBirth.CompareTo(student.DateOfBirth));
            }
            else
            {
                throw new Exception("Невозможно сравнить два объекта");
            }
        }
Beispiel #4
0
        public int CompareTo(Skier other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var idComparison = Id.CompareTo(other.Id);

            if (idComparison != 0)
            {
                return(idComparison);
            }
            var firstNameComparison = string.Compare(FirstName, other.FirstName, StringComparison.Ordinal);

            if (firstNameComparison != 0)
            {
                return(firstNameComparison);
            }
            var lastNameComparison = string.Compare(LastName, other.LastName, StringComparison.Ordinal);

            if (lastNameComparison != 0)
            {
                return(lastNameComparison);
            }
            var dateOfBirthComparison = DateOfBirth.CompareTo(other.DateOfBirth);

            if (dateOfBirthComparison != 0)
            {
                return(dateOfBirthComparison);
            }
            var nationComparison = string.Compare(Nation, other.Nation, StringComparison.Ordinal);

            if (nationComparison != 0)
            {
                return(nationComparison);
            }
            var profileImageComparison = string.Compare(ProfileImage, other.ProfileImage, StringComparison.Ordinal);

            if (profileImageComparison != 0)
            {
                return(profileImageComparison);
            }
            return(string.Compare(Sex, other.Sex, StringComparison.Ordinal));
        }
Beispiel #5
0
        public int CompareTo(object obj)
        {
            Player that = (Player)obj;

            return(DateOfBirth.CompareTo(that.DateOfBirth));
        }
Beispiel #6
0
 public int CompareTo(Human human)
 {
     return(DateOfBirth.CompareTo(human.DateOfBirth));
 }