public async Task <ActionResult <ExpenseDto> > CreateExpenseAsync(CreateExpenseDto createExpenseDto) { Expense expense = new() { Id = Guid.NewGuid(), Category = createExpenseDto.Category, Price = createExpenseDto.Price, DateOfExpense = DateTimeOffset.UtcNow }; await repository.CreateExpenseAsync(expense); return(CreatedAtAction(nameof(CreateExpenseAsync), new { id = expense.Id }, expense.AsDto())); }
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())); }