Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            int hashFirstName = Name == null ? 0 : Name.GetHashCode();
            int hashLastName  = Jmbag == null ? 0 : Jmbag.GetHashCode();

            return(hashFirstName ^ hashLastName);
        }
Ejemplo n.º 2
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (string.IsNullOrEmpty(Jmbag) || Jmbag.Length != 10 || !Jmbag.All(_ => char.IsDigit(_)))
     {
         yield return(new ValidationResult("JMBAG se mora sastojati od 10 znamenki", new[] { "Jmbag" }));
     }
 }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            int hashName  = Name.GetHashCode();
            int hashJmbag = Jmbag.GetHashCode();

            return(hashName ^ hashJmbag);
        }
Ejemplo n.º 4
0
 public bool Equals(Student another)
 {
     if (Jmbag.Equals(another.Jmbag))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public override bool Equals(object obj)
 {
     if (!(obj is Student objAStudent))
     {
         return(false);
     }
     return(Jmbag.Equals(objAStudent.Jmbag));
 }
Ejemplo n.º 6
0
 public bool Equals(Student s)
 {
     if (Jmbag.Equals(s.Jmbag))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
0
 public override bool Equals(object obj)
 {
     if (obj == null || Jmbag == null)
     {
         return(false);
     }
     return(Jmbag.Equals(((Student)obj).Jmbag));
 }
Ejemplo n.º 8
0
        public override int GetHashCode()
        {
            int hashName  = Name == null ? 0 : Name.GetHashCode();
            int hashJmbag = Jmbag == null ? 0 : Jmbag.GetHashCode();

            int hash = hashName ^ hashJmbag;

            return(hash);
        }
Ejemplo n.º 9
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Jmbag != null ? Jmbag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)Gender;
         return(hashCode);
     }
 }
Ejemplo n.º 10
0
        public override bool Equals(object obj)
        {
            if (obj is Student)
            {
                Student student1 = (Student)obj;
                return(Name.Equals(student1.Name) && Jmbag.Equals(student1.Jmbag) && (Gender == student1.Gender));
            }

            return(false);
        }
Ejemplo n.º 11
0
        public override bool Equals(object obj)
        {
            var student = obj as Student;

            if (ReferenceEquals(student, null))
            {
                return(false);
            }

            return(Jmbag.Equals(student.Jmbag));
        }
Ejemplo n.º 12
0
 public override int GetHashCode()
 {
     if (Name == null || Jmbag == null)
     {
         return(0);
     }
     else
     {
         return(Name.GetHashCode() ^ Jmbag.GetHashCode());
     }
 }
Ejemplo n.º 13
0
        public override int GetHashCode()

        {
            // If two products are equal, they will have the same hash code.

            // Two products are equal if their ID matches, so the easiest way to do this is

            // just to return the Id.GetHashCode().

            return(Jmbag.GetHashCode());
        }
Ejemplo n.º 14
0
        public override bool Equals(object obj)
        {
            var item = obj as Student;

            if (item == null)
            {
                return(false);
            }

            return(Jmbag.Equals(item.Jmbag) && Name.Equals(item.Name) && Gender.Equals(item.Gender));
        }
Ejemplo n.º 15
0
        public IDictionary <string, string> Validate()
        {
            var errors = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(Jmbag) || Jmbag.Length != 10 || !Jmbag.All(_ => char.IsDigit(_)))
            {
                errors.Add(nameof(Jmbag), "Invalid JMBAG.");
            }

            if (string.IsNullOrWhiteSpace(Firstname))
            {
                errors.Add(nameof(Firstname), "Firstname is required.");
            }

            if (string.IsNullOrWhiteSpace(Lastname))
            {
                errors.Add(nameof(Lastname), "Lastname is required.");
            }

            return(errors);
        }
Ejemplo n.º 16
0
 public override int GetHashCode() => Jmbag.GetHashCode();
Ejemplo n.º 17
0
 public override int GetHashCode()
 {
     return(Jmbag.GetHashCode());
 }
Ejemplo n.º 18
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() * 17 + Jmbag.GetHashCode());
 }
Ejemplo n.º 19
0
        public override int GetHashCode()
        {
            int i = Gender == Gender.Male ? 1 : 0;

            return(Name.GetHashCode() + Jmbag.GetHashCode() + i + 7);
        }
Ejemplo n.º 20
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Jmbag != null ? Jmbag.GetHashCode() : 0));
     }
 }
Ejemplo n.º 21
0
        public override int GetHashCode()
        {
            unchecked
            {
                // Choose large primes to avoid hashing collisions
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Name) ? Name.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Jmbag) ? Jmbag.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Gender) ? Gender.GetHashCode() : 0);
                return(hash);
            }
        }
Ejemplo n.º 22
0
 public override int GetHashCode()
 {
     return(Jmbag.GetHashCode() * Name.GetHashCode() * Gender.GetHashCode());
 }
        public override bool Equals(object obj)
        {
            var stud = obj as Student;

            return(stud != null && Jmbag.Equals(stud.Jmbag));
        }