public static void CreateDefaultPageTemplatesPerTeam(IConsoleRepository ConsoleRepository, TemplatedPage templatedPage, List<Team> teams, Template structureTemplate, Template holdingTemplate)
 {
     foreach (var team in teams)
     {
         SetPageTemplates(ConsoleRepository, templatedPage, structureTemplate, holdingTemplate, team);
     } 
 }
        public static void SetPageTemplates(IConsoleRepository ConsoleRepository, TemplatedPage templatedPage,
                                             Template structureTemplate, Template holdingTemplate, Team team)
        {
            var pageStructureTemplate = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = structureTemplate,
                    PageSectionId = 0
                };
            ConsoleRepository.Add<PageTemplate>(pageStructureTemplate);

            var holdingTempl_1 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 1
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_1);

            var holdingTempl_2 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 2
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_2);

            var holdingTempl_3 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 3
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_3);

            var holdingTempl_4 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 4
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_4);

            var holdingTempl_5 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 5
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_5);

            var holdingTempl_6 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 6
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_6);

            var holdingTempl_7 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 7
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_7);

            var holdingTempl_8 = new PageTemplate
                {
                    IsVisible = true,
                    Team = team,
                    TemplatedPage = templatedPage,
                    Template = holdingTemplate,
                    PageSectionId = 8
                };
            ConsoleRepository.Add<PageTemplate>(holdingTempl_8);
        }
        public TemplateDto CreateTemplate(TemplateDto templateDto)
        {
            using (ConsoleRepository)
            {
                var template = ConsoleRepository.Query<Template>().FirstOrDefault(t => t.Title.Equals(templateDto.Title));

                if (template != null) throw new Exception("Template Already Exists");

                var newTemplate = new Template
                {
                    Title = templateDto.Title,
				    Url = templateDto.Url,
				    IsPageStructureTemplate = templateDto.IsPageStructureTemplate,
				    AfterRenderDomFunction = templateDto.AfterRenderDomFunction
                };
                ConsoleRepository.Add<Template>(newTemplate);
                ConsoleRepository.SaveChanges();

                templateDto.Id = newTemplate.Id;
            }

            return templateDto;
        }