public async Task <Unit> Handle(DeleteShortTermExpenseCommand command, CancellationToken cancellationToken) { await _repository.DeleteShortTermExpense(command.ShortTermExpenseId); await _repository.SaveAsync(); return(Unit.Value); }
public async Task <Unit> Handle(AddShortTermExpenseCommand command, CancellationToken cancellationToken) { var prediction = await _repository.GetPredictionByPredictionId(command.PredictionId); prediction.AddShortTermExpense( command.Name, command.ExecutionDate, new Money(command.Amount, command.Currency)); await _repository.SaveAsync(); return(Unit.Value); }
public async Task <Unit> Handle(UpdateShortTermExpenseCommand command, CancellationToken cancellationToken) { var shortTermExpense = await _repository.GetShortTermExpenseById(command.ShortTermExpenseId); var update = new ShortTermExpense(shortTermExpense.PredictionId, command.Name, command.ExecutionDate, new Money(command.Amount, command.Currency)); shortTermExpense.Update(update); _repository.UpdateShortTermExpense(shortTermExpense); await _repository.SaveAsync(); return(Unit.Value); }