示例#1
0
        public void AddNewBlogPostTest()
        {
            BlogPost blogPost = new BlogPost()
            {
                User = new ApplicationUser()
                {
                    Id = "aef7943d-d5da-4570-98b5-378a077ecfa6"
                },
                BlogPostTitle = "Coding or Love?",
                BlogPostText =
                "<p>There is power in understanding the journey of others to help create your own. I have always drawn on my muses for inspiration. During my formative years living abroad in Italy, I&rsquo;d devour the VHS tapes of C#&nbsp;stars of the &rsquo;80s that my grandfather would send across the Atlantic. Later on, when I moved back to America and was the kid in school who dressed differently and had trouble reading and writing in English, Coding&nbsp;was my outlet, my source of power.</p>" +
                "<p> Coding & nbsp;is the vehicle through which I question myself. It & rsquo; s the vehicle in which I learn about myself.</p> " +
                "<p> Now, after 18 years in the CodingBA, I want to show you the journey. The pain, the sacrifice, the disappointments and the glory.I want to show you what it really means to chase greatness.</p>" +
                "<p> &nbsp;</p>",
                TimeCreated = DateTime.Parse("2015 - 12 - 07 12:21:27"),
                Status = PageStatus.Approved,
                Category = new Category()
                {
                    CategoryId = 4
                },
                Description = "The other day I made a big life decision.",
                CoverImageUrl = "http://i.imgur.com/aooqCVq.png"
            };

            var returned = _repo.AddNewBlogPost(blogPost);

            Assert.AreEqual(blogPost.User.Id, returned.User.Id);
            Assert.AreEqual(blogPost.BlogPostTitle, returned.BlogPostTitle);
            Assert.AreEqual(blogPost.BlogPostText, returned.BlogPostText);
            Assert.AreEqual(blogPost.TimeCreated, returned.TimeCreated);
            Assert.AreEqual(blogPost.Status, returned.Status);
            Assert.AreEqual(blogPost.Category.CategoryId, returned.Category.CategoryId);
            Assert.AreEqual(blogPost.Description, returned.Description);
            Assert.AreEqual(blogPost.CoverImageUrl, returned.CoverImageUrl);
        }
示例#2
0
        public AddBlogPostVM()
        {
            BlogPost = new BlogPost();

            hashtags = new List<string>();

            CategoriesList = new List<SelectListItem>();
        }
示例#3
0
        public Response EditBlogPost(BlogPost b)
        {
            _response = new Response();
            var blogPost = _repo.EditBlogPost(b);

            if (blogPost != null)
            {
                _response.Success = true;
                _response.BlogPost = blogPost;
            }

            return _response;
        }
示例#4
0
 public Response()
 {
     Users = new List<ApplicationUser>();
     IdUserRoles = new List<IdentityUserRole>();
     IdRoles = new List<IdentityRole>();
     Hashtag = new Hashtag();
     Hashtags = new List<Hashtag>();
     BlogPost = new BlogPost();
     BlogPosts = new List<BlogPost>();
     StaticPage = new StaticPage();
     StaticPages = new List<StaticPage>();
     Category = new Category();
     Categories = new List<Category>();
     User = new ApplicationUser();
     BlogStats = new BlogStats();
 }
示例#5
0
        public void TestAddNewBlogPost()
        {
            var blogpost = new BlogPost();

            blogpost.BlogPostTitle = "Tim's Top 3 Cities";
            blogpost.BlogPostId = 1;
            blogpost.Category.CategoryId = 3;
            blogpost.BlogPostText = "<p>1. &nbsp;Kaohsiung, Taiwan</p>" +
                                    "<p><img src = \"http://p1-news.yamedia.tw/MTA3Mjc4NG5ld3M=/d7551d6961dea5a6.jpg\" alt = \"Kaohsiung\" width = \"516\" height = \"417\" /></p>" +
                                    "<p> 2. & nbsp; Taichung, Taiwan </p><p><img src = \"https://travel.yam.com/DATA/ARTICLE/20140715143433380.jpg\" alt = \"Taichung\" width = \"517\" height = \"343\"/></p>" +
                                    "<p> 3. & nbsp; Tokyo, Japan </p> <p><img src = \"https://ict.swisscom.ch/wp-content/uploads/2015/09/tokyo.jpg\" alt = \"Tokyo\" width = \"524\" height = \"262\"/></p>";
            blogpost.TimeCreated = DateTime.Parse("2015 - 12 - 07 12:01:39.170");
            blogpost.Description = "Gotta love traveling!";
            blogpost.CoverImageUrl = "http://p1-news.yamedia.tw/MTA3Mjc4NG5ld3M=/d7551d6961dea5a6.jpg";

            Assert.AreEqual(true, _ops.AddNewBlogPost(blogpost).Success);
        }
示例#6
0
        private BlogPost PopulateBlogPostFromReader(SqlDataReader dr)
        {
            BlogPost blogPost = new BlogPost();

            blogPost.BlogPostId = (int)dr["BlogPostID"];
            blogPost.BlogPostTitle = dr["BlogPostTitle"].ToString();
            blogPost.BlogPostText = dr["BlogPostText"].ToString();
            blogPost.TimeCreated = DateTime.Parse(dr["TimeCreated"].ToString());
            if (dr["ExpirationDate"] != DBNull.Value)
            {
                blogPost.ExpirationDate = DateTime.Parse(dr["ExpirationDate"].ToString());
            }
            blogPost.Status = (PageStatus)dr["Status"];
            blogPost.Category.CategoryId = (int)dr["CategoryID"];
            blogPost.Category.CategoryTitle = dr["CategoryTitle"].ToString();
            blogPost.Description = dr["Description"].ToString();
            blogPost.CoverImageUrl = dr["CoverImageUrl"].ToString();
            blogPost.User = PopulateUserFromDataReader(dr);

            return blogPost;
        }
示例#7
0
        private List<Hashtag> AddHashtags(BlogPost blogPost, SqlConnection cn)
        {
            foreach (var hashtag in blogPost.Hashtags)
            {
                var checkHashtag = GetAllHashtags().FirstOrDefault(h => h.HashtagTitle == hashtag.HashtagTitle);
                var p = new DynamicParameters();

                if (checkHashtag == null)
                {
                    p = new DynamicParameters();
                    p.Add("@HashtagTitle", hashtag.HashtagTitle);
                    p.Add("@HashtagID", dbType: DbType.Int32, direction: ParameterDirection.Output);

                    cn.Execute("AddNewHashtag", p, commandType: CommandType.StoredProcedure);

                    hashtag.HashtagId = p.Get<int>("HashtagID");

                    p = new DynamicParameters();
                    p.Add("@BlogPostID", blogPost.BlogPostId);
                    p.Add("@HashtagID", hashtag.HashtagId);

                    cn.Execute("AddBlogPostHashtags", p, commandType: CommandType.StoredProcedure);
                }
                else
                {
                    p = new DynamicParameters();
                    p.Add("@BlogPostID", blogPost.BlogPostId);
                    p.Add("@HashtagID", checkHashtag.HashtagId);

                    cn.Execute("AddBlogPostHashtags", p, commandType: CommandType.StoredProcedure);

                    hashtag.HashtagId = checkHashtag.HashtagId;
                }
            }

            return blogPost.Hashtags;
        }
示例#8
0
        public BlogPost UpdateBlogPostStatus(int blogPostId, PageStatus updatedStatus)
        {
            BlogPost blogPost = new BlogPost();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand();
                cmd.CommandText = "UpdateStatus";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@BlogPostID", blogPostId);
                cmd.Parameters.AddWithValue("@Status", (int)updatedStatus);
                cmd.Connection = cn;
                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        blogPost = PopulateBlogPostFromReader(dr);
                    }
                }
            }

            blogPost.Hashtags = GetHashtagByBlogPostId(blogPost.BlogPostId);

            return blogPost;
        }
示例#9
0
        public BlogPost GetBlogPostById(int blogPostId)
        {
            BlogPost blogPost = new BlogPost();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "GetBlogPostByID";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@BlogPostID", blogPostId);
                cmd.Connection = cn;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        blogPost = PopulateBlogPostFromReader(dr);
                    }
                }

                blogPost.Hashtags = GetHashtagByBlogPostId(blogPost.BlogPostId);
            }

            return blogPost;
        }
示例#10
0
        public BlogPost AddNewBlogPost(BlogPost blogPost)
        {
            //var hashtags = GetAllHashtags();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var p = new DynamicParameters();
                p.Add("@UserID", blogPost.User.Id);
                p.Add("@BlogPostTitle", blogPost.BlogPostTitle);
                p.Add("@BlogPostText", blogPost.BlogPostText);
                p.Add("@TimeCreated", blogPost.TimeCreated);
                p.Add("@Status", (int)blogPost.Status);
                p.Add("@CategoryID", blogPost.Category.CategoryId);
                p.Add("@Description", blogPost.Description);
                p.Add("@CoverImageUrl", blogPost.CoverImageUrl);
                p.Add("@BlogPostID", DbType.Int32, direction: ParameterDirection.Output);

                cn.Execute("AddNewBlogPost", p, commandType: CommandType.StoredProcedure);

                blogPost.BlogPostId = p.Get<int>("BlogPostID");

                if (blogPost.Hashtags != null)
                {

                    blogPost.Hashtags = AddHashtags(blogPost, cn);

                    //foreach (var hashtag in blogPost.Hashtags)
                    //{
                    //    var checkHashtag = hashtags.FirstOrDefault(h => h.HashtagTitle == hashtag.HashtagTitle);

                    //    if (checkHashtag == null)
                    //    {
                    //        p = new DynamicParameters();
                    //        p.Add("@HashtagTitle", hashtag.HashtagTitle);
                    //        p.Add("@HashtagID", dbType: DbType.Int32, direction: ParameterDirection.Output);

                    //        cn.Execute("AddNewHashtag", p, commandType: CommandType.StoredProcedure);

                    //        hashtag.HashtagId = p.Get<int>("HashtagID");

                    //        p = new DynamicParameters();
                    //        p.Add("@BlogPostID", blogPost.BlogPostId);
                    //        p.Add("@HashtagID", hashtag.HashtagId);

                    //        cn.Execute("AddBlogPostHashtags", p, commandType: CommandType.StoredProcedure);
                    //    }
                    //    else
                    //    {
                    //        p = new DynamicParameters();
                    //        p.Add("@BlogPostID", blogPost.BlogPostId);
                    //        p.Add("@HashtagID", checkHashtag.HashtagId);

                    //        cn.Execute("AddBlogPostHashtags", p, commandType: CommandType.StoredProcedure);

                    //        hashtag.HashtagId = checkHashtag.HashtagId;
                    //    }
                    //}

                }

                blogPost = GetBlogPostById(blogPost.BlogPostId);

                return blogPost;
            }
        }
示例#11
0
        public BlogPost EditBlogPost(BlogPost blogPost)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var p = new DynamicParameters();
                p.Add("@BlogPostID", blogPost.BlogPostId);
                p.Add("@BlogPostTitle", blogPost.BlogPostTitle);
                p.Add("@BlogPostText", blogPost.BlogPostText);
                p.Add("@Status", (int)blogPost.Status);
                p.Add("@CategoryID", blogPost.Category.CategoryId);
                p.Add("@Description", blogPost.Description);
                p.Add("@CoverImageUrl", blogPost.CoverImageUrl);

                cn.Execute("EditBlogPost", p, commandType: CommandType.StoredProcedure);

                if (blogPost.HashtagsUpdated)
                {
                    p = new DynamicParameters();
                    p.Add("@BlogPostID", blogPost.BlogPostId);

                    cn.Execute("DeleteBlogPostHashtagsByBlogPostID", p, commandType: CommandType.StoredProcedure);

                    AddHashtags(blogPost, cn);
                }
            }

            blogPost = GetBlogPostById(blogPost.BlogPostId);

            return blogPost;
        }
示例#12
0
        public void EditBlogPostTest()
        {
            BlogPost blogPost = new BlogPost()
            {
                BlogPostId = 14,
                User = new ApplicationUser()
                {
                    Id = "aef7943d-d5da-4570-98b5-378a077ecfa6"
                },
                BlogPostTitle = "Coding or Love~~~",
                BlogPostText =
                "<p>There is power in understanding the journey of others to help create your own. I have always drawn on my muses for inspiration. During my formative years living abroad in Italy, I&rsquo;d devour the VHS tapes of C#&nbsp;stars of the &rsquo;80s that my grandfather would send across the Atlantic. Later on, when I moved back to America and was the kid in school who dressed differently and had trouble reading and writing in English, Coding&nbsp;was my outlet, my source of power.</p>" +
                "<p> Coding & nbsp;is the vehicle through which I question myself. It & rsquo; s the vehicle in which I learn about myself.</p> " +
                "<p> Now, after 18 years in the CodingBA, I want to show you the journey. The pain, the sacrifice, the disappointments and the glory.I want to show you what it really means to chase greatness.</p>" +
                "<p> &nbsp;</p>" +
                "<p> Oh Yeah...</p>",
                TimeCreated = DateTime.Parse("2015 - 12 - 07 12:21:27"),
                Status = PageStatus.Pending,
                Category = new Category()
                {
                    CategoryId = 3
                },
                Description = "The other day I made a big life decision...",
                CoverImageUrl = "http://vignette1.wikia.nocookie.net/minecraft/images/4/48/150px-Creeper.png/revision/latest?cb=20140101094930"
            };

            var actual = _repo.EditBlogPost(blogPost);

            Assert.AreEqual(blogPost.User.Id, actual.User.Id);
            Assert.AreEqual(blogPost.BlogPostTitle, actual.BlogPostTitle);
            Assert.AreEqual(blogPost.BlogPostText, actual.BlogPostText);
            Assert.AreEqual(blogPost.TimeCreated, actual.TimeCreated);
            Assert.AreEqual(blogPost.Status, actual.Status);
            Assert.AreEqual(blogPost.Category.CategoryId, actual.Category.CategoryId);
            Assert.AreEqual(blogPost.Description, actual.Description);
            Assert.AreEqual(blogPost.CoverImageUrl, actual.CoverImageUrl);
        }
        public ActionResult Create(int? id)
        {
            var node = SiteMaps.Current.FindSiteMapNodeFromKey("BlogPosts_Create");

            // if Category Selected and We Have it
            if (id != null)
            {
                ViewBag.CategoryId = new SelectList(db.Categories.Where(x => x.ParentId != 0), "Id", "Name", id);
                // SiteMap and Breadcrumb
                Category category = db.Categories.Find(id);
                if (node.ParentNode != null)
                {
                    node.ParentNode.Title = category.Name;
                    node.ParentNode.RouteValues["id"] = category.Id;
                }
            }
            else
            {
                ViewBag.CategoryId = new SelectList(db.Categories.Where(x => x.ParentId != 0), "Id", "Name");
                if (node.ParentNode != null)
                {
                    node.ParentNode.Title = "شاخه نامشخص";
                    node.ParentNode.RouteValues["id"] = "";
                }
            }

            BlogPost post = new BlogPost();
            post.PublishDate = DateTime.Now;
            return View(post);
        }
示例#14
0
文件: Seed.cs 项目: nlivaic/Blog
        public static IWebHost SeedData(this IWebHost webhost)
        {
            Author[] AllAuthors = new Author[] {
                new Author("Ross Geller"),
                new Author("Rosina Pledger"),
                new Author("Ted Pitchford"),
                new Author("Jarvis Templeman"),
                new Author("Hoyt Pendergraft"),
                new Author("Meg Ritzer"),
                new Author("Laine Rosson"),
                new Author("Ariel Alkire"),
                new Author("Donovan Curling"),
                new Author("Jeannie Fallin"),
                new Author("Hoa Carvalh")
            };
            BlogPost[] AllBlogs = new BlogPost[] {
                new BlogPost("Emperor Of Dawn", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed rhoncus nec enim mollis mattis. Nunc porta quam ac nibh iaculis, in mattis eros rhoncus. Curabitur pellentesque lacus a odio semper, eu sodales est vulputate. Quisque vehicula, massa at placerat mattis, sem ligula placerat velit, ut congue metus sem ut erat. Maecenas mauris urna, cursus eu nisi vitae, facilisis eleifend enim. Nulla consequat orci ut felis rhoncus dapibus. Integer arcu tortor, semper sed ullamcorper eget, imperdiet vel ante. Mauris lacinia tellus dolor, in placerat erat commodo id.", AllAuthors[10].Id),
                new BlogPost("Criminal Without Fear", "Proin fermentum tempor mauris id vulputate. Maecenas a turpis blandit, ultricies turpis id, fermentum nulla. Suspendisse potenti. Maecenas et sem sed felis sollicitudin vulputate. Proin semper leo ac nisl suscipit porta. Cras a blandit tellus. Nulla facilisi.", AllAuthors[1].Id),
                new BlogPost("Serpents With Pride", "Phasellus quis ipsum eget sem convallis euismod ut suscipit tortor. Proin viverra augue ac ligula aliquet pellentesque. Suspendisse sit amet dignissim nisl. Nam vitae nibh a arcu iaculis interdum at vel nibh. Donec feugiat lacus mi, sed consequat lorem tincidunt at. Vivamus non bibendum arcu. Vestibulum luctus nunc tellus, vitae dapibus nulla tincidunt eget. Ut pharetra nisi sit amet risus ullamcorper, id lacinia odio rutrum. Integer ultricies urna massa, eu aliquet enim euismod in.", AllAuthors[6].Id),
                new BlogPost("Assassins Of The Forsaken", "Praesent efficitur tempus scelerisque. Suspendisse non faucibus nisl. Aliquam eget pellentesque lacus. Curabitur nec leo magna. Curabitur ut dui sit amet est lacinia blandit. Vestibulum maximus egestas neque, nec dapibus velit egestas at. Nulla suscipit tempor risus vel consectetur. Fusce non rhoncus elit. Maecenas vitae lectus finibus, varius nisi sit amet, ultricies ipsum. Etiam lacinia velit ex, a fermentum enim pellentesque in.", AllAuthors[7].Id),
                new BlogPost("Agents And Criminals", "Maecenas venenatis mollis erat, malesuada vestibulum lorem tempus maximus. Sed ac nunc commodo, dignissim nulla vel, sagittis elit. Vivamus non rhoncus purus, eget iaculis metus. Nunc et urna in risus mollis accumsan ac et lectus. Vivamus non congue leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam gravida consectetur ullamcorper.", AllAuthors[5].Id),
                new BlogPost("Giants And Companions", "Integer lobortis consectetur faucibus. Nulla facilisi. Curabitur vel ornare dui. Nullam ultrices risus vel nisi sodales, vel feugiat velit fringilla. Sed pharetra odio vel urna scelerisque mollis. Suspendisse fringilla elementum iaculis. In sed mauris nec arcu malesuada accumsan sit amet in dui. Aliquam vel metus ut augue condimentum molestie sed vel purus.", AllAuthors[8].Id),
                new BlogPost("Doom Without Desire", "Nulla placerat non magna eu euismod. Aliquam erat volutpat. Nam vitae fermentum sem, in dapibus massa. Sed faucibus facilisis tempus. Mauris lobortis cursus felis sit amet elementum. Duis enim erat, accumsan et dignissim eu, dictum eget magna. Fusce porttitor luctus quam a porta. Nunc vestibulum vulputate sagittis. Suspendisse varius lacinia neque vitae semper. Ut pellentesque mauris leo, et viverra risus vehicula eu. Suspendisse potenti. Nunc aliquam vel libero et fringilla.", AllAuthors[4].Id),
                new BlogPost("Birth Of Sorrow", "Sed sed erat sem. Nulla efficitur ultrices enim, eu finibus nisl convallis at. Sed non mattis arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus condimentum facilisis enim vitae ultrices. Morbi pharetra at risus id dictum. Vestibulum scelerisque laoreet tincidunt. Curabitur quis pharetra arcu, id pharetra nisi. Phasellus laoreet gravida leo, sit amet bibendum libero bibendum ac.", AllAuthors[3].Id),
                new BlogPost("Dancing In The Abyss", "Vivamus ultricies consequat vestibulum. Morbi diam dui, lobortis vitae ornare at, varius et urna. Suspendisse sed tellus nec est molestie sagittis nec vitae eros. Integer lacinia dui sem, sit amet malesuada eros faucibus sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer aliquet nisl sit amet posuere suscipit. Fusce augue lacus, varius et mollis vel, condimentum a magna. Sed ac placerat eros. Aliquam blandit arcu metus, sit amet tincidunt eros elementum ut. Phasellus in nisi eu ligula euismod sagittis.", AllAuthors[9].Id),
                new BlogPost("Walking The Abyss", "Nam rhoncus a lorem ut placerat. Vestibulum ac semper magna. Cras quis est pulvinar, laoreet enim at, mattis nisi. Praesent vulputate, elit eu dapibus gravida, erat sapien vehicula metus, a ullamcorper mi sem non sapien. Aenean nec tortor vitae purus bibendum semper eget vel enim. Nam quis felis orci. Quisque vehicula nulla odio, ac dignissim nisl facilisis quis. Praesent egestas, tortor non vulputate lobortis, erat sapien commodo eros, id congue nunc magna ultrices libero.", AllAuthors[2].Id),
                new BlogPost("Descendant Of Silver", "Nam suscipit cursus odio, nec sollicitudin enim. Sed cursus, metus vel viverra faucibus, odio nibh faucibus quam, et ultricies lectus nisl vitae nulla. Proin luctus dignissim enim, et tristique mi scelerisque eu. Cras eget leo non tortor facilisis ultricies a in magna. Nulla hendrerit imperdiet velit, vel egestas nunc bibendum nec. Pellentesque mattis, ipsum nec malesuada interdum, mi nulla rutrum leo, nec facilisis lacus mi nec quam. Morbi eu diam at erat elementum pulvinar id vitae sapien. Etiam ornare lectus et neque fermentum, vitae laoreet leo ultrices. Nulla interdum libero eu lacus vestibulum, sed cursus quam mollis. Pellentesque bibendum tortor sit amet diam suscipit vehicula. Nunc mattis at tellus eu faucibus. Cras purus nulla, vulputate nec auctor non, ornare et eros.", AllAuthors[8].Id),
                new BlogPost("Raven Without A Goal", "Sed laoreet, odio et suscipit scelerisque, leo enim consectetur urna, ut auctor augue sapien quis justo. Integer nec dui tortor. Quisque posuere congue venenatis. Suspendisse sapien libero, rhoncus vitae tincidunt sodales, varius in lectus. Etiam consectetur porttitor ultrices. Mauris id rutrum tortor. Etiam sit amet vulputate sapien.", AllAuthors[5].Id),
                new BlogPost("Gods Without A Conscience", "Nullam accumsan ut lorem a cursus. Proin id facilisis dolor. Integer sollicitudin sit amet ex id dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque in malesuada augue, eget dapibus metus. Pellentesque vestibulum iaculis mi ut pretium. Vivamus fermentum risus id tellus cursus, eget suscipit justo convallis. Phasellus feugiat sapien est, vel tincidunt ex porta et. Aliquam ac risus ligula. Fusce risus nibh, volutpat gravida tempus facilisis, efficitur vitae lacus.", AllAuthors[6].Id),
                new BlogPost("Bandits With Honor", "Maecenas consequat eu lorem mattis sagittis. Fusce eget viverra justo. Praesent in aliquam ex, eget posuere lorem. Morbi suscipit luctus nisl consequat laoreet. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam blandit ligula non vulputate vehicula. Vestibulum sed lacus accumsan urna malesuada bibendum a sit amet leo. Praesent vel mauris lectus. Integer vitae interdum erat. Quisque sollicitudin ante non suscipit pulvinar. Donec eleifend a mauris eu euismod. Proin justo nulla, porttitor eu erat eleifend, venenatis euismod lectus. Nulla et sem in dui tempus pretium vel non ipsum. In hac habitasse platea dictumst. Curabitur vel ante id dui imperdiet eleifend ac sit amet purus. Aenean dolor arcu, volutpat in porta ut, dignissim vitae leo.", AllAuthors[7].Id),
                new BlogPost("Gangsters And Lions", "Sed quis libero pharetra, mollis lectus ac, pellentesque quam. In consectetur purus non interdum commodo. In accumsan, lorem eu sagittis tristique, tellus ligula malesuada metus, eu porta sem velit porttitor orci. Nam consectetur risus eu dolor aliquet iaculis. Nam convallis dolor quis augue euismod, a sollicitudin augue sagittis. Etiam ut dignissim lectus. Sed eget egestas risus. Nam ac lacus lacinia, laoreet erat in, posuere purus. Nam vel quam lectus. Ut placerat vel mauris vitae malesuada. Vestibulum ullamcorper urna non sem egestas faucibus. Suspendisse molestie fermentum urna ut consectetur. Suspendisse quis ornare lorem.", AllAuthors[2].Id),
                new BlogPost("Warriors And Turtles", "Duis condimentum mi mattis mattis semper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam sollicitudin ut risus ut mattis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis commodo dolor sit amet nulla bibendum pretium. In commodo gravida congue. Vestibulum euismod velit eu metus aliquam volutpat. Ut sed lorem odio. Curabitur ac ipsum sit amet diam tristique bibendum nec ac nisl.", AllAuthors[1].Id),
                new BlogPost("Anger Without A Home", "In hac habitasse platea dictumst. Duis semper molestie massa, ut varius felis pellentesque sit amet. Nam lacus massa, fermentum ac tortor a, pulvinar euismod orci. Nulla non nunc aliquet, ultrices quam non, vestibulum ex. Curabitur in augue elit. Pellentesque rutrum mi ultrices, interdum ex ac, semper purus. In vehicula nisl nec gravida convallis. Cras vel mi velit. Fusce ac elit nec magna facilisis aliquam a venenatis nisl.", AllAuthors[10].Id),
                new BlogPost("Faith Of Fortune", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pellentesque, orci tincidunt accumsan vehicula, nibh nibh pellentesque lectus, rutrum scelerisque ex urna in elit. Nam commodo convallis feugiat. Aenean malesuada elementum dolor eget varius. Praesent volutpat consequat lorem, id auctor nisi ornare sit amet. Ut tempus tortor sit amet ultrices porta. Maecenas interdum ornare sodales. Mauris aliquam eros vestibulum, vestibulum eros quis, accumsan urna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum vel massa vitae turpis volutpat consequat. Maecenas arcu sem, semper lacinia commodo consequat, efficitur a urna.", AllAuthors[4].Id),
                new BlogPost("Meeting At The Hunter", "Proin hendrerit enim et felis scelerisque, quis iaculis erat scelerisque. Phasellus feugiat vitae felis eu sagittis. In hac habitasse platea dictumst. Ut felis est, bibendum sit amet vulputate eget, suscipit ut diam. Sed nisl erat, sollicitudin a pellentesque nec, faucibus id mi. Nulla ut eleifend quam. Mauris dapibus felis nulla, eget imperdiet lacus hendrerit aliquet. Morbi rutrum metus a purus auctor, sed pulvinar tellus dapibus. Nam vitae imperdiet dolor. Vivamus vel laoreet diam. Donec suscipit tristique metus ut scelerisque. Pellentesque posuere finibus posuere. Ut et enim id felis finibus porttitor id quis dui. Vestibulum ut arcu sit amet nisl ullamcorper luctus et lobortis urna.", AllAuthors[3].Id),
                new BlogPost("Inventing Secrets", "Aenean congue risus metus. Mauris dui quam, semper nec augue vel, iaculis posuere urna. Ut felis lorem, aliquet vitae pellentesque suscipit, malesuada ac ex. Fusce at suscipit purus. Integer sed laoreet odio, nec venenatis magna. Nulla commodo quam felis, a egestas est suscipit sodales. Morbi in ex pellentesque eros posuere accumsan. Sed sed fringilla magna. Curabitur non nunc quis nulla posuere pulvinar. Duis fermentum imperdiet semper.", AllAuthors[9].Id),
                new BlogPost("Guardians Of My Imagination", "Pellentesque facilisis viverra urna vitae ullamcorper. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer tortor quam, congue feugiat nisl vitae, tempus facilisis eros. Morbi placerat sed risus a tristique. Aliquam gravida odio ut nisi condimentum, in porta mi egestas. Nulla sit amet velit id odio viverra interdum ut eget lorem. Mauris feugiat felis eu felis facilisis, at consequat ex iaculis. Sed vitae pharetra urna. Morbi ac lobortis tellus. Nam sit amet maximus tortor. Quisque nisi odio, faucibus a vehicula eu, fermentum vitae odio. Maecenas porttitor lorem ex, ut varius nunc ullamcorper eget.", AllAuthors[3].Id),
                new BlogPost("Invaders Of Heaven", "Vivamus nibh justo, vulputate eu semper at, laoreet vel nisi. Mauris eget fermentum diam, vitae sollicitudin magna. Donec iaculis faucibus nisl, non vestibulum lorem ornare at. Nulla ultricies, turpis nec sagittis varius, nisl orci sodales lorem, ut tincidunt nisl felis quis enim. Aenean lacinia tortor vitae molestie sodales. Integer lobortis ipsum in maximus venenatis. Integer nec elit quis eros efficitur accumsan pharetra et ex. Suspendisse ac massa quis ante mollis luctus ac et ipsum. Fusce imperdiet, nisl et sollicitudin scelerisque, ligula velit dapibus nulla, sed ullamcorper neque nisl eget metus. Donec vitae dolor lacus. Pellentesque consectetur est vitae blandit ornare. Duis eget pretium justo.", AllAuthors[5].Id),
                new BlogPost("Priests And Mice", "Suspendisse eu felis quam. Aliquam vitae lorem magna. Praesent facilisis sollicitudin felis non interdum. Suspendisse potenti. Vivamus ac consectetur risus. In euismod ac orci vitae ornare. Maecenas eget justo at nibh rhoncus ultricies vel eu lorem. Nam sed congue felis, sit amet convallis dui.", AllAuthors[2].Id),
                new BlogPost("Thieves And Blacksmiths", "Nunc semper ullamcorper vestibulum. Vestibulum a quam arcu. Donec a ultricies neque. Donec consectetur ut augue vitae bibendum. Quisque ac aliquet leo, ut egestas quam. In hac habitasse platea dictumst. Suspendisse vulputate ex et arcu auctor pellentesque. Aliquam cursus dapibus porta. Nunc euismod ante hendrerit bibendum rhoncus.", AllAuthors[9].Id)
            };
            Comment[] AllComments = new Comment[] {
                new Comment("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", AllAuthors[8].Id, AllBlogs[7].Id),
                new Comment("Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", AllAuthors[7].Id, AllBlogs[21].Id),
                new Comment("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", AllAuthors[3].Id, AllBlogs[1].Id),
                new Comment("Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", AllAuthors[7].Id, AllBlogs[13].Id),
                new Comment("Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.", AllAuthors[6].Id, AllBlogs[4].Id),
                new Comment("Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.", AllAuthors[4].Id, AllBlogs[7].Id),
                new Comment("Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.", AllAuthors[8].Id, AllBlogs[18].Id),
                new Comment("Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?", AllAuthors[3].Id, AllBlogs[9].Id),
                new Comment("Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?", AllAuthors[2].Id, AllBlogs[0].Id),
                new Comment("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.", AllAuthors[5].Id, AllBlogs[19].Id),
                new Comment("No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.", AllAuthors[4].Id, AllBlogs[13].Id),
                new Comment("Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure.", AllAuthors[6].Id, AllBlogs[22].Id),
                new Comment("To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?", AllAuthors[7].Id, AllBlogs[0].Id),
                new Comment("At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.", AllAuthors[9].Id, AllBlogs[12].Id),
                new Comment("Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.", AllAuthors[7].Id, AllBlogs[8].Id),
                new Comment("Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae.", AllAuthors[1].Id, AllBlogs[11].Id),
                new Comment("Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.", AllAuthors[5].Id, AllBlogs[13].Id),
                new Comment("On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain.", AllAuthors[9].Id, AllBlogs[14].Id),
                new Comment("These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided.", AllAuthors[7].Id, AllBlogs[8].Id),
                new Comment("But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.", AllAuthors[4].Id, AllBlogs[13].Id),
                new Comment("The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.", AllAuthors[10].Id, AllBlogs[21].Id),
                new Comment("Postoje mnoge varijacije odlomaka iz Lorem Ipsum-a, ali većina je pretrpjela kojekakve promjene s dodanim humorom, ili nasumičnim riječima koje nikako tu ne spadaju. Ako trebate koristiti Lorem Ipsum, morate biti sigurni da tekst ne sadrži skrivene nepodobne riječi ili fraze.", AllAuthors[10].Id, AllBlogs[21].Id),
                new Comment("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", AllAuthors[6].Id, AllBlogs[15].Id),
                new Comment("Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", AllAuthors[6].Id, AllBlogs[23].Id),
                new Comment("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", AllAuthors[6].Id, AllBlogs[15].Id),
                new Comment("Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", AllAuthors[3].Id, AllBlogs[7].Id),
                new Comment("Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.", AllAuthors[6].Id, AllBlogs[18].Id),
                new Comment("Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.", AllAuthors[7].Id, AllBlogs[6].Id),
                new Comment("Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.", AllAuthors[6].Id, AllBlogs[17].Id),
                new Comment("Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?", AllAuthors[6].Id, AllBlogs[11].Id),
                new Comment("Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?", AllAuthors[8].Id, AllBlogs[1].Id),
                new Comment("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.", AllAuthors[10].Id, AllBlogs[20].Id),
                new Comment("No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.", AllAuthors[10].Id, AllBlogs[4].Id),
                new Comment("Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure.", AllAuthors[4].Id, AllBlogs[19].Id),
                new Comment("To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?", AllAuthors[3].Id, AllBlogs[20].Id),
                new Comment("At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.", AllAuthors[3].Id, AllBlogs[3].Id),
                new Comment("Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.", AllAuthors[9].Id, AllBlogs[1].Id),
                new Comment("Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae.", AllAuthors[6].Id, AllBlogs[3].Id),
                new Comment("Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.", AllAuthors[4].Id, AllBlogs[9].Id),
                new Comment("On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain.", AllAuthors[10].Id, AllBlogs[5].Id),
                new Comment("These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided.", AllAuthors[9].Id, AllBlogs[21].Id),
                new Comment("But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.", AllAuthors[4].Id, AllBlogs[3].Id),
                new Comment("The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.", AllAuthors[8].Id, AllBlogs[6].Id),
                new Comment("Postoje mnoge varijacije odlomaka iz Lorem Ipsum-a, ali većina je pretrpjela kojekakve promjene s dodanim humorom, ili nasumičnim riječima koje nikako tu ne spadaju. Ako trebate koristiti Lorem Ipsum, morate biti sigurni da tekst ne sadrži skrivene nepodobne riječi ili fraze.", AllAuthors[10].Id, AllBlogs[4].Id)
            };

            using (var scope = webhost.Services.GetService <IServiceScopeFactory>().CreateScope())
            {
                using (BlogContext ctx = scope.ServiceProvider.GetRequiredService <BlogContext>())
                {
                    if (!ctx.Authors.Any())
                    {
                        ctx.Authors.AddRange(AllAuthors);
                        ctx.BlogPosts.AddRange(AllBlogs);
                        ctx.Comments.AddRange(AllComments);
                        ctx.SaveChanges();
                    }
                }
            }
            return(webhost);
        }