Skip to content

Instantly share code, notes, and snippets.

@zainafzal88
Created October 7, 2020 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zainafzal88/4119548e55865c56524c152f3962cfee to your computer and use it in GitHub Desktop.
Save zainafzal88/4119548e55865c56524c152f3962cfee to your computer and use it in GitHub Desktop.
[HttpPost]
public async Task Post([FromBody] Comments comment)
{
Guid uuid = Guid.NewGuid();
var item = new Dictionary<string, AttributeValue>()
{
{"id", new AttributeValue{S = uuid.ToString()}},
{"username", new AttributeValue{S = comment.Username}},
{"comment", new AttributeValue{S = comment.Comment}},
{"postId", new AttributeValue{S = comment.PostId}},
{"date", new AttributeValue{S = DateTime.Now.ToString()}}
};
PutItemRequest request = new PutItemRequest
{
TableName = TableName,
Item = item
};
await _amazonDynamoDb.PutItemAsync(request);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment