using System;
using System.Collections.Generic;
using skyscraper5.Skyscraper.Scraper.Storage;

namespace skyscraper5.Skyscraper.Equipment
{
	public static class EquipmentUtilities
	{
		public static void InsertDefaultLnbTypes(IScraperStroage storage)
		{
			List<LnbType> knownLnbTypes = storage.UiLnbTypesListAll();
			foreach (LnbType defaultLnbType in GetDefaultLnbTypes())
			{
				if (!knownLnbTypes.Contains(defaultLnbType))
					storage.UiLnbTypesAdd(defaultLnbType);
			}
		}

		private static IEnumerable<LnbType> GetDefaultLnbTypes()
		{
			LnbType lnbType = new LnbType();
			lnbType.Lof1 = 9750;
			lnbType.Lof2 = 10600;
			lnbType.LofSw = 11700;
			lnbType.MinimumFrequency = 10700;
			lnbType.MaximumFrequency = 12750;
			lnbType.Name = "Generic Universal LNB";
			yield return lnbType;
		}

		public static void InsertDefaultDishTypes(IScraperStroage storage)
		{
			List<DishType> knownDishTypes = storage.UiDishTypesListAll();
			foreach (DishType defaultDishType in GetDefaultDishTypes())
			{
				if (!knownDishTypes.Contains(defaultDishType))
					storage.UiDishTypesAdd(defaultDishType);
			}
		}

		private static IEnumerable<DishType> GetDefaultDishTypes()
		{
			int[] commonSizes = new int[] { 60, 80, 85, 100 };
			foreach (int commonSize in commonSizes)
			{
				DishType dishType = new DishType();
				dishType.Diameter = commonSize;
				dishType.Shape = DishShape.Offset;
				dishType.Name = String.Format("Generic {0} cm Offset dish antenna", commonSize);
				yield return dishType;
			}
		}
	}
}
