public async Task <IActionResult> EditExpense([FromBody] EditExpenseRequest request) { var expense = request.ToDto(); await _expenseManerger.EditExpenseAsync(expense); return(Created(Request.Path, expense.WrapResponse(Request.Path))); }
public async Task <IActionResult> Edit(EditExpenseRequest request) { if (!ModelState.IsValid) { return(Failure()); } return(await _expenseService.Edit(request)); }
public async Task <IActionResult> Edit(EditExpenseRequest request) { var expense = _context.Expenses.Where(i => i.Id == request.ExpenseId).Include(i => i.Currency).Include(i => i.Category).FirstOrDefault(); if (expense == null) { return(Failure()); } expense.Amount = request.Amount; await _context.SaveChangesAsync(); return(Success(ConvertToVM(expense))); }