Exemplo n.º 1
0
        public async Task <ActionResult <ExpenseDto> > CreateExpenseAsync(CreateExpenseDto expenseToCreate)
        {
            var newExpense = new Expense
            {
                Id = Guid.NewGuid(),
                ApplicationUserId = expenseToCreate.ApplicationUserId,
                Price             = expenseToCreate.Price,
                Description       = expenseToCreate.Description,
                DateOfExpense     = DateTimeOffset.UtcNow,
                CategoryId        = expenseToCreate.CategoryId
            };

            await _expensesRepository.CreateExpenseAsync(newExpense);

            return(CreatedAtAction(nameof(CreateExpenseAsync), new { id = newExpense.Id }, newExpense.AsDto()));
        }