Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Last active March 2, 2022 18:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save awswithdotnet/7b7c9d9168b862c9f49866bfba8b2583 to your computer and use it in GitHub Desktop.
DynamoDB DynamoDB VehicleController.cs Post
[HttpPost]
public async Task<IActionResult> Post(Vehicle vehicle)
{
Table table = Table.LoadTable(_client, "Vehicles");
var vehicleDocument = new Document();
vehicleDocument["VIN"] = vehicle.Vin;
vehicleDocument["YearManufactured"] = vehicle.Year;
vehicleDocument["Make"] = vehicle.Make;
vehicleDocument["Model"] = vehicle.Model;
await table.PutItemAsync(vehicleDocument);
return Created("/vehicle/" + vehicle.Vin, vehicle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment