async Task <Transaction> IRequestHandler <CreateTransactionCommand, Transaction> .Handle(CreateTransactionCommand transactionCmd, CancellationToken cancellationToken) { var mdrAdquirente = await _mdrRepository.GetById(transactionCmd.Adquirente); if (mdrAdquirente == null) { _notificationDomainService.Add(code: NotificationMessages.MdrAdquirenteNotExistKey, value: NotificationMessages.MdrAdquirenteNotExistValue); return(null); } var newTransaction = Transaction.Create(mdrAdquirente: mdrAdquirente, valor: transactionCmd.Valor, tipo: transactionCmd.Tipo, bandeira: transactionCmd.Bandeira); newTransaction = _transactionRepository.Add(newTransaction); return(newTransaction); }
public OperationResultVo <Guid> Save(Guid currentUserId, NotificationItemViewModel viewModel) { try { Notification model; Notification existing = notificationDomainService.GetById(viewModel.Id); if (existing != null) { model = mapper.Map(viewModel, existing); } else { model = mapper.Map <Notification>(viewModel); } if (viewModel.Id == Guid.Empty) { notificationDomainService.Add(model); viewModel.Id = model.Id; } else { notificationDomainService.Update(model); } unitOfWork.Commit(); return(new OperationResultVo <Guid>(model.Id)); } catch (Exception ex) { return(new OperationResultVo <Guid>(ex.Message)); } }