private Operation CreateOperation(TransactionCreateRequest request, DateTime operationDateTime)
        {
            var operationToCreate = new Operation
            {
                Date        = operationDateTime,
                Description = request.OperationDetails + $"{operationDateTime}"
            };

            _repository.Operation.Create(operationToCreate);

            return(operationToCreate);
        }
        public Task <IEnumerable <TransactionModel> > Handle(TransactionCreateRequest request, CancellationToken cancellationToken)
        {
            var transactionsToCreate = _mapper.Map <IEnumerable <Transaction> >(request.Transactions);

            using (_repository.UseTransaction())
            {
                var operationDate = DateTime.Now;
                var operation     = CreateOperation(request, operationDate);

                transactionsToCreate.ToList().ForEach(t =>
                {
                    t.Operation   = operation;
                    t.OperationId = operation.Id;
                    t.Date        = operationDate;
                });

                _repository.TransactionRepository.CreateMany(transactionsToCreate);
            }

            var result = _mapper.Map <IEnumerable <TransactionModel> >(transactionsToCreate);

            return(Task.FromResult(result));
        }