public List <Post> GetAllPostsForBlogAsList(BlogExtended currentBlog)
        {
            var posts = _serv.GetAllPostsForCurrentBlog(currentBlog).ToList();

            if (posts.Where(x => x.Title == "Add new").Count() == 0)
            {
                posts.Add(new Post()
                {
                    Title = "Add new"
                });
            }
            return(posts);
        }
        public void DeleteBlog(BlogExtended currentBlog)
        {
            var existingBlog = _db.Blogs.Where(x => x.BlogId == currentBlog.BlogId).FirstOrDefault();

            if (existingBlog != null)
            {
                //foreach (var post in existingBlog.Posts)
                //{
                //    foreach (var comment in post.Comments)
                //    {
                //        _db.Comments.Remove(comment);
                //    }
                //    _db.SaveChanges();
                //    _db.Posts.Remove(post);
                //}
                //_db.SaveChanges();
                _db.Blogs.Remove(existingBlog);
                _db.SaveChanges();
            }
        }
 public void DeleteBlog(BlogExtended currentBlog)
 {
     _serv.DeleteBlog(currentBlog);
 }
 public void RevertBlog(BlogExtended currentBlog)
 {
     _serv.RevertBlogs();
 }
 public IEnumerable <Post> GetAllPostsForCurrentBlog(BlogExtended currentBlog)
 {
     return(_db.Posts.Include(x => x.Blog).Where(x => x.Blog == currentBlog));
 }
 public BlogExtended DeletePost(BlogExtended currentBlog, Post currentPost)
 {
     _serv.DeletePost(currentPost);
     currentBlog.Posts.Remove(currentPost);
     return(currentBlog);
 }