using System;
using System.Runtime.Serialization;

using BS.Shared.DataContracts.Compact;

namespace BS.Shared.DataContracts
{
	[DataContract, Serializable]
	public class Employee2SchedulerAppointmentDC : IDataContract
	{
		[DataMember]
		public long? Employee2SchedulerAppointmentOid { get; set; }

		[DataMember]
		public long? Employee2SchedulerAppointmentVersion { get; set; }

		[DataMember]
		public CompactEmployeeDC Employee { get; set; }

		[DataMember]
		public ParticipationAnswer ParticipationAnswer { get; set; }

		[DataMember]
		public long? SchedulerAppointmentOid { get; set; }

		[DataMember]
		public bool IsPChanged { get; set; }

		[DataMember]
		public DateTime? IsPC_CheckedTs { get; set; }

		public override bool Equals(object obj)
		{
			if (!(obj is Employee2SchedulerAppointmentDC))
			{
			    return false;
			}

			var y = (Employee2SchedulerAppointmentDC) obj;

			if (Employee2SchedulerAppointmentOid == null && y.Employee2SchedulerAppointmentOid == null)
			{
			    return GetHashCode() == y.GetHashCode();
			}

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

			var sindGleich = Employee.Equals(y.Employee) && ParticipationAnswer == y.ParticipationAnswer && SchedulerAppointmentOid == y.SchedulerAppointmentOid;

			return sindGleich;
		}

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