Skip to content

Commit

Permalink
Add create method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferenc Hammerl committed Oct 20, 2020
1 parent d4040c3 commit c5cb8f3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ExpenseTracker.Api/Controllers/ExpenseController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using ExpenseTracker.Models;
Expand Down Expand Up @@ -36,6 +36,14 @@ public async Task<IActionResult> Get(int id)
}
return Ok(expense);
}

[HttpPost]
public async Task<IActionResult> Create(Expense expense)
{
ctx.Expenses.Add(expense);
await ctx.SaveChangesAsync();
return Ok(expense);
}
}
}
}

0 comments on commit c5cb8f3

Please sign in to comment.