Esempio n. 1
0
        /// <summary>
        /// Adds a new transactions on the remote node asynchronously. Secret, Amount and RecipientId are required
        /// </summary>
        /// <param name="req">Transaction details</param>
        /// <returns>TransactionAddResponse with transactionId</returns>
        public async Task <TransactionAddResponse> AddTransactionAsync(TransactionAddRequest req)
        {
            _url.Path = Constants.ApiPutAddTransaction;
            var response = await _client.PutJsonAsync <TransactionAddRequest, TransactionAddResponse>(_url.ToString(), req);

            ResetPath();
            return(response);
        }
Esempio n. 2
0
 public async Task <UpdateTransactionResponse> Post([FromBody] TransactionAddRequest transaction)
 {
     if (_postTransactionProcessor != null)
     {
         return(await _postTransactionProcessor.PostNewTransactionRecord(transaction, _cloudantService));
     }
     else
     {
         return(new UpdateTransactionResponse());
     }
 }
        public static TransactionAddMqRequest ToMqModel(this TransactionAddRequest transactionAddRequest)
        {
            var transactionAddMqRequest = new TransactionAddMqRequest()
            {
                ClientId = transactionAddRequest.ClientId,
                Amount   = transactionAddRequest.Amount,
                Currency = (CurrencyMqModel)(int)transactionAddRequest.Currency,
            };

            return(transactionAddMqRequest);
        }
Esempio n. 4
0
        public async Task <TransactionAddResponse> AddAsync(TransactionAddRequest transactionAddRequest)
        {
            TransactionAddMqRequest transactionAddMqRequest = transactionAddRequest.ToMqModel();

            transactionAddMqRequest.DepartmentAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();

            using var bus = CreateBus();

            TransactionAddMqResponse transactionAddMqResponse = await bus.RequestAsync <TransactionAddMqRequest, TransactionAddMqResponse>(transactionAddMqRequest);

            return(transactionAddMqResponse.ToModel());
        }
Esempio n. 5
0
        public async Task <UpdateTransactionResponse> PostNewTransactionRecord(TransactionAddRequest transactionAddRequest, ICloudantService cloudantService = null)
        {
            if (cloudantService != null)
            {
                var response = await cloudantService.CreateAsync(transactionAddRequest, DBNames.transaction.ToString());

                return(JsonConvert.DeserializeObject <UpdateTransactionResponse>(response));
            }
            else
            {
                return(new UpdateTransactionResponse());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Adds a new transactions on the remote node synchronously. Secret, Amount and RecipientId are required
        /// </summary>
        /// <param name="req">Transaction details</param>
        /// <returns>TransactionAddResponse with transactionId</returns>
        public TransactionAddResponse AddTransaction(TransactionAddRequest req)
        {
            var response = AddTransactionAsync(req).GetAwaiter().GetResult();

            return(response);
        }
        public async Task <IActionResult> Add([FromBody] TransactionAddRequest transactionAddRequest)
        {
            TransactionAddResponse transactionAddResponse = await _transactionService.AddAsync(transactionAddRequest);

            return(Ok(transactionAddResponse));
        }