/// <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); }
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); }
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()); }
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()); } }
/// <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)); }