Exemplo n.º 1
0
 public override int GetHashCode()
 {
     return(Surname.GetHashCode()
            ^ Patronimic.GetHashCode() * 17
            ^ Name.GetHashCode() * 19
            * BirthYear.GetHashCode());
 }
Exemplo n.º 2
0
        public int CompareTo(Student student2)
        {
            if (student2 is null)
            {
                return(1);
            }

            int result = string.CompareOrdinal(Surname, student2.Surname);

            if (result != 0)
            {
                return(result);
            }

            result = string.CompareOrdinal(Name, student2.Name);
            if (result != 0)
            {
                return(result);
            }

            result = string.CompareOrdinal(Patronimic, student2.Patronimic);
            if (result != 0)
            {
                return(result);
            }

            return(BirthYear.CompareTo(student2.BirthYear));
        }
Exemplo n.º 3
0
        public void Validate()
        {
            if (!String.IsNullOrEmpty(Gender) && Gender != "m" && Gender != "f")
            {
                throw new ArgumentException("Gender");
            }

            BirthYear.ValidateOptional("BirthYear");
            Country.ValidateOptional("Country");
            State.ValidateOptional("State");
            FirstDayOfWeek.ValidateOptional("FirstDayOfWeek");
            Languages.ValidateOptional <Language>("Languages");
        }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 23;
         hash = hash * 37 + (Number != null ? Number.GetHashCode() : 0);
         hash = hash * 37 + (Name != null ? Name.GetHashCode() : 0);
         hash = hash * 37 + (BirthYear != null ? BirthYear.GetHashCode() : 0);
         hash = hash * 37 + (Height != null ? Height.GetHashCode() : 0);
         hash = hash * 37 + (Role != null ? Role.GetHashCode() : 0);
         return(hash);
     }
 }
Exemplo n.º 5
0
 private bool ValidateField(KeyValuePair <string, string> kvp)
 {
     var(key, value) = kvp;
     return(key switch
     {
         "byr" => BirthYear.IsValid(value),
         "iyr" => IssueYear.IsValid(value),
         "eyr" => ExpirationYear.IsValid(value),
         "hgt" => Height.IsValid(value),
         "hcl" => HairColour.IsValid(value),
         "ecl" => EyeColour.IsValid(value),
         "pid" => PassportId.IsValid(value),
         "cid" => true,
         _ => false
     });
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 23;
         hash = hash * 37 + Id.GetHashCode();
         hash = hash * 37 + (Number != null ? Number.GetHashCode() : 0);
         hash = hash * 37 + (FullName != null ? FullName.GetHashCode() : 0);
         hash = hash * 37 + (NationalityCode != null ? NationalityCode.GetHashCode() : 0);
         hash = hash * 37 + (Nationality != null ? Nationality.GetHashCode() : 0);
         hash = hash * 37 + (BirthYear != null ? BirthYear.GetHashCode() : 0);
         hash = hash * 37 + (Position != null ? Position.GetHashCode() : 0);
         hash = hash * 37 + (Height != null ? Height.GetHashCode() : 0);
         return(hash);
     }
 }
Exemplo n.º 7
0
        public UserModel(TblUser row)
        {
            Id        = row.Id;
            Name      = row.Name;
            LastName  = row.LastName;
            TelNumber = row.TelNumber;
            Email     = row.Email;
            Active    = row.Active;
            ClubId    = row.ClubId;
            TrainerId = row.TrainerId;
            BirthYear = row.BirthYear;
            Lytis     = row.Lytis;
            Name2     = Name + " " + LastName;

            if (BirthYear.ToString().Length == 22)
            {
                BirthYear2 = BirthYear.ToString().Substring(0, 10);
            }
            else if (BirthYear.ToString().Length == 20)
            {
                BirthYear2 = BirthYear.ToString().Substring(0, 8);
            }
            else
            {
                BirthYear2 = BirthYear.ToString().Substring(0, 9);
            }

            String[] datearray = BirthYear2.Split('/');
            BirthYear2 = datearray[2] + "-";
            if (datearray[0].Length == 1)
            {
                BirthYear2 += "0" + datearray[0] + "-";
            }
            else
            {
                BirthYear2 += datearray[0] + "-";
            }

            if (datearray[1].Length == 1)
            {
                BirthYear2 += "0" + datearray[1];
            }
            else
            {
                BirthYear2 += datearray[1];
            }
        }
Exemplo n.º 8
0
 public int?Age()
 {
     return(BirthYear.Age(DeathYear ?? new Year(DateTime.Now)));
 }
Exemplo n.º 9
0
 private bool IsBirthYearValid() =>
 BirthYear.IsDigitWithLength(4, out var birthYear) && birthYear.IsBetween(1920, 2002);
Exemplo n.º 10
0
 get => _bdate ?? (_bdate = new DateTime(BirthYear, BirthMonth, BirthDay));
Exemplo n.º 11
0
 public override string ToString()
 {
     return (FirstName.PadRight(20) + LastName.PadRight(20)
         + LicensedDriver.ToString().PadRight(20) + BirthYear.ToString().PadRight(20)
         + FavoriteColor.ToString().PadRight(20));
 }
Exemplo n.º 12
0
 public override string ToString()
 {
     return($"{Color} animal was born in {BirthYear.ToString("dd/MM/yyyy")}, his age is {GetAge(BirthYear)}, he say - " + Voice());
 }