using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.EMMA;
using TravelCompanyBusinessLogic.OfficePackage.HelperEnums;
using TravelCompanyBusinessLogic.OfficePackage.HelperModels;

namespace TravelCompanyBusinessLogic.OfficePackage
{
    public abstract class AbstractSaveToWord
    {
        public void CreateGuidesDoc(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 reportGuideView in info.Guides)
            {
                CreateParagraph(new WordParagraph
                {
                    Texts = new List<(string, WordTextProperties)>
                    {
                        ("Путешествие: ", new WordTextProperties { Bold = true, Size = "26" }),
                        (reportGuideView.Travel.TravelName, new WordTextProperties { Bold = false, Size = "24" }),
                        (" Дата начала путешествия: ", new WordTextProperties { Bold = true, Size = "24" }),
                        (reportGuideView.Travel.DateStart.ToString(), new WordTextProperties { Bold = false, Size = "24" })
                    },
                    TextProperties = new WordTextProperties
                    {
                        Size = "24",
                        JustificationType = WordJustificationType.Both
                    }
                });

                CreateParagraph(new WordParagraph
                {
                    Texts = new List<(string, WordTextProperties)>
                        {
                            ("Гиды путешествия: ", new WordTextProperties { Bold = true, Size = "24" })
                        },
                    TextProperties = new WordTextProperties
                    {
                        Size = "24",
                        JustificationType = WordJustificationType.Both
                    }
                });

                foreach (var guide in reportGuideView.Guides)
                {
                    CreateParagraph(new WordParagraph
                    {
                        Texts = new List<(string, WordTextProperties)>
                        {
                            ($"{guide.Surname} {guide.Name} {guide.Patronymic}", new WordTextProperties { Bold = false, Size = "24" })
                        },
                        TextProperties = new WordTextProperties
                        {
                            Size = "24",
                            JustificationType = WordJustificationType.Both
                        }
                    });
                }
            }

            SaveWord(info);
        }
        protected abstract void CreateWord(WordInfo info);
        protected abstract void CreateParagraph(WordParagraph paragraph);
        protected abstract void SaveWord(WordInfo info);
    }
}
