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
[HttpDelete("{id}")] | |
public async Task Delete(string id) | |
{ | |
var request = new DeleteItemRequest | |
{ | |
TableName = TableName, | |
Key = new Dictionary<string, AttributeValue>() | |
{ | |
{"id", new AttributeValue{S = id}} | |
} |
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
[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}}, |
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
public class Comments | |
{ | |
public string Username { get; set; } | |
public string Comment { get; set; } | |
public string PostId { get; set; } | |
} |
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
<script> | |
$(function(){ | |
let allComments = document.getElementById("all-comments"); | |
let $name = $("#name"); | |
let $comment = $("#comment"); | |
$("#submit").on('click', function(){ | |
//validation to prevent html tags being inputted input box |
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
<div class="comments-view"> | |
<h4>Please Share Thoughts</h4> | |
<input id="name" type="name" class="form-control" placeholder="Enter your email"> | |
<textarea id="comment" class="form-control" placeholder="Share thoughts here"></textarea> | |
<button id="submit" class="btn btn-primary" >Comment</button> | |
<div id="all-comments" class="show-comments"></div> | |
</div> |
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
private const string TableName = "comments"; | |
private readonly IAmazonDynamoDB _amazonDynamoDb; | |
public CommentsController(IAmazonDynamoDB amazonDynammoDb) | |
{ | |
_amazonDynamoDb = amazonDynammoDb; | |
} | |
[HttpGet] | |
public async Task<ScanResponse> GetComments() |
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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Transform": "AWS::Serverless-2016-10-31", | |
"Description": "An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.", | |
"Resources": { | |
"AspNetCoreFunction": { | |
"Type": "AWS::Serverless::Function", | |
"Properties": { | |
"Handler": "CommentsAPI::CommentsAPI.LambdaEntryPoint::FunctionHandlerAsync", | |
"Runtime": "dotnetcore3.1", |