private void InitializeViewModel(BlogPost blogPost)
 {
     Author = blogPost.Author;
     Title = blogPost.Title;
     Content = blogPost.Content;
     Category = blogPost.Category;
 }
        public BlogPostViewModel(BlogPost blogPost)
        {
            if (blogPost == null) throw new ArgumentNullException(nameof(blogPost));
            this.blogPost = blogPost;

            InitializeViewModel(blogPost);
        }
        // newly blogpost
        // edit existing blogpost
        public void Save(BlogPost blogPost)
        {
            if (blogPost == null) throw new ArgumentNullException(nameof(blogPost));

            var index = blogPosts.FindIndex(post => post.Id == blogPost.Id);
            if (index != -1)
            {
                blogPosts[index] = blogPost;
                return;
            }

            blogPosts.Add(blogPost);
        }
        public void Remove(BlogPost blogPost)
        {
            if (blogPost == null) throw new ArgumentNullException(nameof(blogPost));

            blogPosts.Remove(blogPost);
        }