Skip to content

Conversation

@barrera77
Copy link

  1. Added CreatePost endpoint in the PostsController:
  • [HttpPost] public ActionResult CreatePost([FromBody] PostDto postDto)
  • This receives the post JSON, validates it, calls the service to create it, and returns 201 Created with the new slug.
  1. Implemented CreatePost in PostService:
  • Maps the incoming PostDto to a Post entity.
  • Generates a new GUID automatically for Id if none is provided.
  • Sets CreatedDate if not provided.
  • Adds the post to the database and calls _context.SaveChanges().
  • Converts the saved entity back to PostDto and returns it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant