namespace BS.Shared.DataContracts
{
    public partial class OrganisationPersonRelationDC
    {
        public override bool Equals(object obj)
        {
            if (obj is OrganisationPersonRelationDC)
            {
                var y = (OrganisationPersonRelationDC)obj;
                if (Organisation2PersonOid == null && y.Organisation2PersonOid == null)
                    return GetHashCode() == y.GetHashCode();

                if (Organisation2PersonOid != null && y.Organisation2PersonOid != null)
                    return Organisation2PersonOid == y.Organisation2PersonOid;
            }

            return false;
        }

        public override int GetHashCode()
        {
            return this.Organisation2PersonOid.HasValue
                       ? GetType().Name.GetHashCode() ^ this.Organisation2PersonOid.GetHashCode()
                       : base.GetHashCode();
        }
    }
}
