﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Composite.Data;
using Composite.Data.Types;
using Composite.Core.PageTemplates;

using Demo;


/// <summary>
/// Summary description for TestCreatePageDemo
/// </summary>
public class TestCreatePageDemo
{
   public static string CreatePage()
   {
       using (DataConnection connection = new DataConnection())
       {
           Guid pageTypeId = connection.Get<IPageType>().First().Id; // grab some page type id 
           Guid templateId = PageTemplateFacade.GetPageTemplates().First(template => template.IsValid).Id; // grab some template id

           Guid parentId = Guid.Empty; // make new website
           CultureInfo pageCulture = new  CultureInfo("da-DK" ); // we will add a Danish page 
           string content = "<h1>This is content</h1><p>Hello world!</p>" ; // test markup

           Guid addedPageId = PageCreationDemo.CreateNewPage(
               parentId,
               pageTypeId,
               templateId, 
               "The Page Title", 
               "Page description...",    
               pageCulture, 
               "Menu Title", 
               "urltitle", 
               content);  

           return string.Format("A page added with ID {0}", addedPageId);
       }
   }
}