コード例 #1
0
        public async Task <IActionResult> AddBeneficiary(string CoinName, short WhitelistingBit, string BeneficiaryAddress, string BeneficiaryName)
        {
            BeneficiaryResponse response = new BeneficiaryResponse();

            try
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                if (user == null)
                {
                    response.BizResponse.ReturnCode = enResponseCode.Fail;
                    response.BizResponse.ReturnMsg  = EnResponseMessage.StandardLoginfailed;
                    response.BizResponse.ErrorCode  = enErrorCode.StandardLoginfailed;
                }
                else
                {
                    var accessToken = await HttpContext.GetTokenAsync("access_token");

                    response = _walletService.AddBeneficiary(CoinName, WhitelistingBit, BeneficiaryName, BeneficiaryAddress, user.Id, accessToken);
                }
                var     respObj     = JsonConvert.SerializeObject(response);
                dynamic respObjJson = JObject.Parse(respObj);
                return(Ok(respObjJson));
            }
            catch (Exception ex)
            {
                //_logger.LogError(ex, "Date: " + _basePage.UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nControllername=" + this.GetType().Name, LogLevel.Error);
                //return BadRequest();
                return(BadRequest(new BizResponseClass {
                    ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
                }));
            }
        }