Created
October 8, 2021 20:49
-
-
Save ankitvijay/374b1aff919ab362a46af20e5529361b to your computer and use it in GitHub Desktop.
NServiceBus Cosmos Sample - Add API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.MapPost("/create", async (IMessageSession messageSession, [FromBody] Post post) => | |
{ | |
var addPostCommand = new Messages.AddPost(post.Title, post.Description, post.Author); | |
await messageSession.Send(addPostCommand); | |
return Results.Accepted(null, new { addPostCommand.PostId }); | |
}); | |
app.MapPost("/add-comment", async (IMessageSession messageSession, [FromBody] Comment comment) => | |
{ | |
var addCommentCommand = new Messages.AddComment(comment.PostId, comment.Content, comment.CommentBy); | |
await messageSession.Send(addCommentCommand); | |
return Results.Accepted(null, new { addCommentCommand.CommentId }); | |
}); | |
app.Run(); | |
public record Post(string Title, string Description, string Author); | |
public record Comment(string PostId, string Content, string CommentBy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment