protected override void Init() { using (var api = new Api(GetDb(), storage, cache)) { Piranha.App.Init(api); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)); postTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; api.Pages.Save(page); var category = new Data.Category() { Id = CAT_1_ID, BlogId = BLOG_ID, Title = "My category" }; api.Categories.Save(category); var post1 = MyPost.Create(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; api.Posts.Save(post1); var post2 = MyPost.Create(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; api.Posts.Save(post2); var post3 = MyPost.Create(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; api.Posts.Save(post3); var post4 = MyCollectionPost.Create(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField() { Value = "First text" }); post4.Texts.Add(new TextField() { Value = "Second text" }); post4.Texts.Add(new TextField() { Value = "Third text" }); api.Posts.Save(post4); } }
protected override void Init() { services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { Piranha.App.Init(); Piranha.App.Fields.Register <MyFourthField>(); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)) .AddType(typeof(MyDIPost)); postTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; api.Pages.Save(page); var category = new Data.Category() { Id = CAT_1_ID, BlogId = BLOG_ID, Title = "My category" }; api.Categories.Save(category); var post1 = MyPost.Create(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); api.Posts.Save(post1); var post2 = MyPost.Create(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; api.Posts.Save(post2); var post3 = MyPost.Create(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; api.Posts.Save(post3); var post4 = MyCollectionPost.Create(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField() { Value = "First text" }); post4.Texts.Add(new TextField() { Value = "Second text" }); post4.Texts.Add(new TextField() { Value = "Third text" }); api.Posts.Save(post4); var post6 = MyDIPost.Create(api); post6.Id = POST_DI_ID; post6.BlogId = BLOG_ID; post6.Category = category; post6.Title = "My Injection Post"; api.Posts.Save(post6); } }