コード例 #1
0
        public async Task <Unit> Handle(DeleteShortTermExpenseCommand command, CancellationToken cancellationToken)
        {
            await _repository.DeleteShortTermExpense(command.ShortTermExpenseId);

            await _repository.SaveAsync();

            return(Unit.Value);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }