using IceCreamShopBusinessLogic.OfficePackage.HelperEnums;
using IceCreamShopBusinessLogic.OfficePackage.HelperModels;

namespace IceCreamShopBusinessLogic.OfficePackage
{
    public abstract class AbstractSaveToWord
    {
        public void CreateDoc(WordInfo info)
        {
            CreateWord(info);

            CreateParagraph(new WordParagraph
            {
                Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
                TextProperties = new WordTextProperties
                {
                    Size = "24",
                    JustificationType = WordJustificationType.Center
                }
            });

            foreach (var iceCream in info.IceCreams)
            {
                CreateParagraph(new WordParagraph
                {
                    Texts = new List<(string, WordTextProperties)> {(iceCream.IceCreamName + " - ", new WordTextProperties { Size = "24", Bold = true}),
                     (iceCream.Price.ToString(), new WordTextProperties { Size = "24", })},
                    TextProperties = new WordTextProperties
                    {
                        Size = "24",
                        JustificationType = WordJustificationType.Both
                    }
                });
            }

            SaveWord(info);
        }

        public void CreateShopsTable(WordInfo info)
        {
            CreateWord(info);

            CreateParagraph(new WordParagraph
            {
                Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
                TextProperties = new WordTextProperties
                {
                    Size = "24",
                    JustificationType = WordJustificationType.Center
                }
            });

            CreateTable(new List<string> { "3000", "3000", "3000" });

            CreateRow(new WordParagraph
            {
                Texts = new List<(string, WordTextProperties)> { ("Название магазина", new WordTextProperties { Size = "24" }), 
                    ("Адрес", new WordTextProperties { Size = "24" }), ("Дата открытия", new WordTextProperties { Size = "24" }) },
                TextProperties = new WordTextProperties
                {
                    Size = "24",
                    Bold = true,
                    JustificationType = WordJustificationType.Center
                }
            });

            foreach (var shop in info.Shops)
            {
                CreateRow(new WordParagraph
                {
                    Texts = new List<(string, WordTextProperties)> { (shop.ShopName, new WordTextProperties { Size = "22" }), 
                        (shop.Address, new WordTextProperties { Size = "22" }), (shop.DateOpening.ToString(), new WordTextProperties { Size = "22" })},
                    TextProperties = new WordTextProperties
                    {
                        Size = "22",
                        JustificationType = WordJustificationType.Center
                    }
                });
            }

            SaveWord(info);
        }

        /// <summary>
		/// Создание doc-файла
		/// </summary>
		/// <param name="info"></param>
        protected abstract void CreateWord(WordInfo info);

        /// <summary>
        /// Создание абзаца с текстом
        /// </summary>
        /// <param name="paragraph"></param>
        /// <returns></returns>
        protected abstract void CreateParagraph(WordParagraph paragraph);

        /// <summary>
		/// Создание таблицы
		/// </summary>
		/// <param name="columns"></param>
        protected abstract void CreateTable(List<string>  columns);

        /// <summary>
		/// Создание строки таблицы
		/// </summary>
		/// <param name="columns"></param>
        protected abstract void CreateRow(WordParagraph paragraph);

        /// <summary>
		/// Сохранение файла
		/// </summary>
		/// <param name="info"></param>
        protected abstract void SaveWord(WordInfo info);
    }
}