diff --git a/ExpenseTracker.Api/Controllers/ExpenseController.cs b/ExpenseTracker.Api/Controllers/ExpenseController.cs index 5f7ada1..6db62b2 100644 --- a/ExpenseTracker.Api/Controllers/ExpenseController.cs +++ b/ExpenseTracker.Api/Controllers/ExpenseController.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using ExpenseTracker.Models; @@ -36,6 +36,14 @@ public async Task Get(int id) } return Ok(expense); } + + [HttpPost] + public async Task Create(Expense expense) + { + ctx.Expenses.Add(expense); + await ctx.SaveChangesAsync(); + return Ok(expense); + } } } }