diff --git a/ExpenseTracker.Api/Controllers/ExpenseController.cs b/ExpenseTracker.Api/Controllers/ExpenseController.cs index 6db62b2..429b7f7 100644 --- a/ExpenseTracker.Api/Controllers/ExpenseController.cs +++ b/ExpenseTracker.Api/Controllers/ExpenseController.cs @@ -44,6 +44,20 @@ public async Task Create(Expense expense) await ctx.SaveChangesAsync(); return Ok(expense); } + + [HttpPut] + public async Task Update(Expense expense) + { + var expenseToUpdate = await ctx.FindAsync(expense.ExpenseID); + if (expenseToUpdate == null) + { + return NotFound(); + } + ctx.Entry(expenseToUpdate).CurrentValues.SetValues(expense); + ctx.SaveChanges(); + return Ok(expense); + } + } } }