private BlogPost CreateNewPost(AddBlogPostRequest request) { var newPost = new BlogPost(); newPost.AuthorId = request.AuthorId; newPost.PostBody = request.PostBody; newPost.PostId = Guid.NewGuid(); newPost.PostTitle = request.PostTitle; newPost.TimeCreated = DateTime.Now; newPost.TimeLastModified = newPost.TimeCreated; return(newPost); }
public AddBlogPostResponse AddBlogPost(AddBlogPostRequest request) { var response = new AddBlogPostResponse(); var newPost = CreateNewPost(request); response.Post = newPost; try { _blogPostRepo.Add(newPost); response.AddSuccessful = true; } catch (Exception) { response.AddSuccessful = false; } return(response); }