예제 #1
0
        public async Task <TransactionGetResponse> GetByIdAsync(TransactionGetByIdRequest transactionGetByIdRequest)
        {
            using var bus = CreateBus();

            TransactionGetMqResponse transactionGetMqResponse = await bus.RequestAsync <TransactionGetByIdMqRequest, TransactionGetMqResponse>(transactionGetByIdRequest.ToMqModel());

            return(transactionGetMqResponse.ToModel());
        }
        public static TransactionGetResponse ToModel(this TransactionGetMqResponse transactionGetMqResponse)
        {
            var transactionGetResponse = new TransactionGetResponse()
            {
                Transaction = transactionGetMqResponse.Transaction.ToModel(),
            };

            return(transactionGetResponse);
        }
        public TransactionGetMqResponse GetById(TransactionGetByIdMqRequest transactionGetByIdMqRequest)
        {
            var transaction = _transactionRepository.GetById(transactionGetByIdMqRequest.ToParameters());

            var transactionGetMessageResponse = new TransactionGetMqResponse()
            {
                Transaction = transaction.ToMqModel(),
            };

            return(transactionGetMessageResponse);
        }
        public static void AddTransactionService(this IBus bus, ITransactionService transactionService)
        {
            bus.Respond <TransactionAddMqRequest, TransactionAddMqResponse>(transactionAddMessageRequest =>
            {
                TransactionAddMqResponse transactionAddMessageResponse = transactionService.Add(transactionAddMessageRequest);

                return(transactionAddMessageResponse);
            });

            bus.Respond <TransactionGetByIdMqRequest, TransactionGetMqResponse>(transactionGetByIdMessageRequest =>
            {
                TransactionGetMqResponse transactionGetMessageResponse = transactionService.GetById(transactionGetByIdMessageRequest);

                return(transactionGetMessageResponse);
            });

            bus.Respond <TransactionGetAllByClientMqRequest, TransactionGetAllMqResponse>(transactionGetByClientMessageRequest =>
            {
                TransactionGetAllMqResponse transactionGetMessageResponse = transactionService.GetAllByClient(transactionGetByClientMessageRequest);

                return(transactionGetMessageResponse);
            });
        }