using BS.Shared.Core;
using BS.Shared.DataContracts.Compact;

namespace BS.Shared.DataContracts
{
    public partial class AdditionalServiceGroupOfPeopleRelationDC : IDataContract
    {
        public override bool Equals(object obj)
        {
            if (obj is AdditionalServiceGroupOfPeopleRelationDC)
            {
                var y = (AdditionalServiceGroupOfPeopleRelationDC)obj;
                if (AdditionalService2GroupOfPeopleOid == null && y.AdditionalService2GroupOfPeopleOid == null)
                    return GetHashCode() == y.GetHashCode();
                if (AdditionalService2GroupOfPeopleOid != null && y.AdditionalService2GroupOfPeopleOid != null)
                    return AdditionalService2GroupOfPeopleOid == y.AdditionalService2GroupOfPeopleOid;
            }

            return false;
        }

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