public async Task <IActionResult> AddPayInAddress([FromBody] PayInAddressModel payInAddress)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResponseFactory.Create(ModelState)));
            }

            var entity = await _addressRepository.GetAsync(payInAddress.Address, payInAddress.Currency);

            if (entity != null)
            {
                return(StatusCode(StatusCodes.Status409Conflict,
                                  ErrorResponse.Create($"Pay-in address {payInAddress.Address} is already in use")));
            }

            await _addressRepository.InsertAsync(payInAddress);

            await _log.WriteInfoAsync(nameof(AddPayInAddress), payInAddress.ToJson(),
                                      "Pay-in address added");

            return(Ok());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds pay-in address info for subsequent transaction check
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='payInAddress'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task AddPayInAddressAsync(this IIcoCommonAPI operations, PayInAddressModel payInAddress = default(PayInAddressModel), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.AddPayInAddressWithHttpMessagesAsync(payInAddress, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 public async Task AddPayInAddressAsync(PayInAddressModel address)
 {
     await _api.AddPayInAddressAsync(address);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds pay-in address info for subsequent transaction check
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='payInAddress'>
 /// </param>
 public static void AddPayInAddress(this IIcoCommonAPI operations, PayInAddressModel payInAddress = default(PayInAddressModel))
 {
     operations.AddPayInAddressAsync(payInAddress).GetAwaiter().GetResult();
 }