public async Task <Unit> Handle(DeleteShortTermIncomeCommand command, CancellationToken cancellationToken) { await _repository.DeleteShortTermIncome(command.ShortTermIncomeId); await _repository.SaveAsync(); return(Unit.Value); }
public async Task <Unit> Handle(AddShortTermIncomeCommand command, CancellationToken cancellationToken) { var prediction = await _repository.GetPredictionById(command.PredictionId); prediction.AddShortTermIncome(command.Name, command.ExecutionDate, new Money(command.Amount, command.Currency)); await _repository.SaveAsync(); return(Unit.Value); }
public async Task <Unit> Handle(UpdateShortTermIncomeCommand command, CancellationToken cancellationToken) { var shortTermIncome = await _repository.GetShortTermIncomeById(command.ShortTermIncomeId); var update = new ShortTermIncome(shortTermIncome.PredictionId, command.Name, command.ExecutionDate, new Money(command.Amount, command.Currency)) { EntityId = command.ShortTermIncomeId }; shortTermIncome.Update(update); _repository.UpdateShortTermIncome(shortTermIncome); await _repository.SaveAsync(); return(Unit.Value); }