예제 #1
0
 private BlogPost UpdatePost(BlogPost oldPost, EditBlogPostRequest request)
 {
     oldPost.PostBody         = request.PostBody;
     oldPost.PostTitle        = request.PostTitle;
     oldPost.TimeLastModified = DateTime.Now;
     return(oldPost);
 }
예제 #2
0
        public EditBlogPostResponse EditBlogPost(EditBlogPostRequest request)
        {
            var response    = new EditBlogPostResponse();
            var postId      = request.PostId;
            var oldPost     = _blogPostRepo.GetById(postId);
            var updatedPost = UpdatePost(oldPost, request);

            response.Post = updatedPost;
            try
            {
                _blogPostRepo.Edit(updatedPost);
                response.EditSuccessful = true;
            }
            catch (Exception)
            {
                response.EditSuccessful = false;
            }
            return(response);
        }