using System;
using System.Collections.Generic;
using skyscraper5.Dvb.Psi.Model;

namespace skyscraper5.Skyscraper.Scraper.Storage.Utilities
{
    public class DatabaseKeyRst : IEquatable<DatabaseKeyRst>
    {
        private uint transportStreamId;
        private uint originalNetworkId;
        private uint serviceId;
        private uint eventId;
        private RunningStatus runningStatus;
        private DateTime currentTime;

        public DatabaseKeyRst(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId, RunningStatus runningStatus, DateTime currentTime)
        {
            this.transportStreamId = transportStreamId;
            this.originalNetworkId = originalNetworkId;
            this.serviceId = serviceId;
            this.eventId = eventId;
            this.runningStatus = runningStatus;
            this.currentTime = currentTime;
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as DatabaseKeyRst);
        }

        public bool Equals(DatabaseKeyRst other)
        {
            return other is not null &&
                   transportStreamId == other.transportStreamId &&
                   originalNetworkId == other.originalNetworkId &&
                   serviceId == other.serviceId &&
                   eventId == other.eventId &&
                   runningStatus == other.runningStatus &&
                   currentTime == other.currentTime;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(transportStreamId, originalNetworkId, serviceId, eventId, runningStatus, currentTime);
        }

        public static bool operator ==(DatabaseKeyRst left, DatabaseKeyRst right)
        {
            return EqualityComparer<DatabaseKeyRst>.Default.Equals(left, right);
        }

        public static bool operator !=(DatabaseKeyRst left, DatabaseKeyRst right)
        {
            return !(left == right);
        }
    }
}
