using MySqlConnector;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper5.Data.MySql
{
		public partial class MySqlDataStorage : DataStorage
		{
			public void DataCarouselModuleMarkComplete(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleModuleId, byte moduleModuleVersion)
			{
			}

			public bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion)
			{
				using (MySqlConnection connection = new MySqlConnection(_mcsb.ToString()))
				{
					connection.Open();
					MySqlCommand command = connection.CreateCommand();
					command.CommandText =
						"SELECT dateadded FROM dsmcc_blacklist WHERE network_id = @network_id AND transport_stream_id = @transport_stream_id AND pid = @pid AND module_id = @module_id " +
						"AND module_version = @module_version";
					command.Parameters.AddWithValue("@network_id", currentNetworkId);
					command.Parameters.AddWithValue("@transport_stream_id", currentTransportStreamId);
					command.Parameters.AddWithValue("@pid", elementaryPid);
					command.Parameters.AddWithValue("@module_id", moduleId);
					command.Parameters.AddWithValue("@module_version", moduleVersion);
					MySqlDataReader dataReader = command.ExecuteReader();
					bool result = dataReader.Read();
					dataReader.Close();
					connection.Close();
					return result;
				}
			}

		}
	}
