Esempio n. 1
0
        public async Task <IActionResult> TransferAsync([FromBody] AirlinesTransferFromDepositRequest request)
        {
            if (!ModelState.IsValid)
            {
                throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors()));
            }

            string opId = await _contractService.RecievePaymentFromDepositContractAsync(request.DepositContractAddress?.ToLower(),
                                                                                        request.TokenAddress?.ToLower(),
                                                                                        request.DestinationAddress?.ToLower(),
                                                                                        request.TokenAmount);

            return(Ok(new OperationIdResponse()
            {
                OperationId = opId
            }));
        }
        private async Task <object> InvokeTransfer(AirlinesTransferFromDepositRequest request)
        {
            object response;

            try
            {
                response = await _ethereumServiceClient.ApiAirlinesErc20depositsTransferPostAsync(
                    _ethereumSettings.ApiKey, request);
            }
            catch (ValidationException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Details,
                    e.Rule,
                    e.Target
                });

                response = new ApiException(new ApiError(ExceptionType.WrongParams, e.Message));
            }

            return(response);
        }