using System;

namespace skyscraper5.Skyscraper.Scraper.Storage.Utilities
{
	public class DatabaseKeyTeletextPage
	{
		public int NetworkId { get; }
		public int TransportStreamId { get; }
		public ushort ProgramNumber { get; }
		public ushort PageNumber { get; }
		public DateTime DateTime { get; }

		public DatabaseKeyTeletextPage(int networkId, int transportStreamId, ushort programNumber, ushort pageNumber, DateTime dateTime)
		{
			NetworkId = networkId;
			TransportStreamId = transportStreamId;
			ProgramNumber = programNumber;
			PageNumber = pageNumber;
			DateTime = dateTime;
		}

		protected bool Equals(DatabaseKeyTeletextPage other)
		{
			return NetworkId == other.NetworkId && TransportStreamId == other.TransportStreamId && ProgramNumber == other.ProgramNumber && PageNumber == other.PageNumber && DateTime.Equals(other.DateTime);
		}

		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((DatabaseKeyTeletextPage)obj);
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(NetworkId, TransportStreamId, ProgramNumber, PageNumber, DateTime);
		}

		public override string ToString()
		{
			return $"{nameof(ProgramNumber)}: {ProgramNumber}, {nameof(PageNumber)}: {PageNumber}, {nameof(DateTime)}: {DateTime}";
		}
	}
}
