public async Task <ExpensesModel> CreateExpense([FromBody] CreateExpenseModel expenseModel) { var result = await _expenseQueryProcessor.Create(expenseModel); var model = _autoMapper.Map <ExpensesModel>(result); return(model); }
public async Task CreateShouldSaveNew() { var model = new CreateExpenseModel { Description = _random.Next().ToString(), Amount = _random.Next(), Comment = _random.Next().ToString(), Date = DateTime.Now }; var result = await _query.Create(model); result.Description.Should().Be(model.Description); result.Amount.Should().Be(model.Amount); result.Comment.Should().Be(model.Comment); result.Date.Should().BeCloseTo(model.Date); result.UserId.Should().Be(_currentUser.Id); _uow.Verify(x => x.Add(result)); _uow.Verify(x => x.CommitAsync()); }