public async Task <IActionResult> EditExpense([FromBody] EditExpenseRequest request)
        {
            var expense = request.ToDto();
            await _expenseManerger.EditExpenseAsync(expense);

            return(Created(Request.Path, expense.WrapResponse(Request.Path)));
        }
示例#2
0
        public async Task <IActionResult> Edit(EditExpenseRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(Failure());
            }

            return(await _expenseService.Edit(request));
        }
示例#3
0
        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)));
        }