Example #1
0
        /// <summary>
        /// Update Blog post View Model
        /// </summary>
        /// <param name="blogViewModel"></param>
        /// <returns></returns>
        public Blog UpdateBlogPost(BlogViewModel blogViewModel)
        {
            var post = blogViewModel.ConvertToBlogModel();

            post.CreationTime = DateTime.Now;
            _blogRepository.Update(post);
            _blogRepository.SaveChanges();
            return(post);
        }
Example #2
0
        /// <summary>
        /// Remove blog Post ViewModel
        /// </summary>
        /// <param name="postId"></param>
        public void RemoveBlogPost(int postId)
        {
            var selectedPost = new BlogViewModel {
                PostId = postId
            };
            var post = selectedPost.ConvertToBlogModel();

            _blogRepository.Delete(post);
            _blogRepository.SaveChanges();
        }