using System;

namespace skyscraper5.Skyscraper.Scraper.Storage.Utilities
{
    public class DatabaseKeyEitEvent
    {
        public ushort ServiceId { get; }
        public ushort TransportStreamId { get; }
        public ushort OriginalNetworkId { get; }
        public ushort EventId { get; }
        public DateTime StartTime { get; }

        public DatabaseKeyEitEvent(ushort serviceId, ushort transportStreamId, ushort originalNetworkId, ushort eventId, DateTime startTime)
        {
            ServiceId = serviceId;
            TransportStreamId = transportStreamId;
            OriginalNetworkId = originalNetworkId;
            EventId = eventId;
            StartTime = startTime;
        }

        protected bool Equals(DatabaseKeyEitEvent other)
        {
            return ServiceId == other.ServiceId && TransportStreamId == other.TransportStreamId && OriginalNetworkId == other.OriginalNetworkId && EventId == other.EventId && StartTime.Equals(other.StartTime);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((DatabaseKeyEitEvent)obj);
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(ServiceId, TransportStreamId, OriginalNetworkId, EventId, StartTime);
        }
    }
}
