Exemple #1
0
        /// <summary>
        /// Seeds some test data.
        /// </summary>
        /// <param name="db"></param>
        private void Seed(IApi api, Piranha.EF.Db db)
        {
            if (db.Categories.Count() == 0)
            {
                // Add the blog category
                var category = new Piranha.EF.Data.Category()
                {
                    Id           = Guid.NewGuid(),
                    Title        = "Blog",
                    ArchiveTitle = "Blog Archive"
                };
                db.Categories.Add(category);

                // Add a post
                var post = new Piranha.EF.Data.Post()
                {
                    CategoryId = category.Id,
                    Title      = "My first post",
                    Excerpt    = "Etiam porta sem malesuada magna mollis euismod.",
                    Body       = "<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>",
                    Published  = DateTime.Now
                };
                db.Posts.Add(post);

                // Add the startpage
                var startPage = Models.StartPageModel.Create("Start");
                startPage.Title       = "Welcome to Piranha CMS";
                startPage.Slug        = "start";
                startPage.Content     = "<p>Lorem ipsum</p>";
                startPage.Intro.Title = "Say hi to the new version of Piranha CMS!";
                startPage.Intro.Body  = "We hope you like it :)";
                startPage.Slider.Add(new Models.SliderItem()
                {
                    Title = "Slide 1",
                    Body  = "<p>Lorem</p>"
                });
                startPage.Slider.Add(new Models.SliderItem()
                {
                    Title = "Slide 2",
                    Body  = "<p>Ipsum</p>"
                });
                startPage.Published = DateTime.Now;
                api.Pages.Save(startPage);

                db.SaveChanges();
            }
        }
Exemple #2
0
        /// <summary>
        /// Seeds some test data.
        /// </summary>
        /// <param name="db"></param>
        private void Seed(IApi api, Piranha.EF.Db db)
        {
            if (api.Categories.Get().Count == 0)
            {
                // Add the startpage
                using (var stream = File.OpenRead("assets/seed/startpage.md")) {
                    using (var reader = new StreamReader(stream)) {
                        var startPage = Models.ContentPageModel.Create("Content");
                        startPage.Title     = "Welcome to Piranha CMS";
                        startPage.Ingress   = "The CMS framework with an extra bite";
                        startPage.Body      = reader.ReadToEnd();
                        startPage.Published = DateTime.Now;
                        api.Pages.Save(startPage);
                    }
                }

                // Add the blog category
                var category = new Piranha.Models.Category()
                {
                    Id           = Guid.NewGuid(),
                    Title        = "Blog",
                    ArchiveTitle = "Blog Archive"
                };
                api.Categories.Save(category);

                // Add a post
                var post = new Piranha.EF.Data.Post()
                {
                    CategoryId = category.Id,
                    Title      = "My first post",
                    Excerpt    = "Etiam porta sem malesuada magna mollis euismod.",
                    Body       = "<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>",
                    Published  = DateTime.Now
                };
                db.Posts.Add(post);
                db.SaveChanges();
            }
        }