예제 #1
0
        public async Task <IActionResult> Kyc()
        {
            var user = await GetUser(required : true);

            // get kyc request url and check the status
            string kycRequestUrl    = null;
            string kycRequestStatus = null;
            var    kycRequest       = _context.KycRequests.Where(r => r.ApplicationUserId == user.Id).OrderByDescending(r => r.Date).FirstOrDefault();

            if (kycRequest != null)
            {
                kycRequestUrl = $"{_kycSettings.KycServerUrl}/request/{kycRequest.Token}";
                var _model = await RestUtils.CheckKycRequest(_logger, _context, _userManager, _kycSettings, user.Id, kycRequest.Token);

                if (_model != null)
                {
                    kycRequestStatus = _model.Status;
                }
            }
            // get users kyc level
            var      levelNum = user.Kyc != null ? user.Kyc.Level : 0;
            KycLevel level    = null;

            if (_kycSettings.Levels.Count > levelNum)
            {
                level = _kycSettings.Levels[levelNum];
            }
            var withdrawalTotalThisPeriod = user.WithdrawalTotalThisPeriod(_kycSettings);
            // convert withdrawal amount to string
            var withdrawalTotalThisPeriodString = _walletProvider.AmountToString(_kycSettings.WithdrawalAsset, withdrawalTotalThisPeriod);

            if (withdrawalTotalThisPeriodString == null)
            {
                withdrawalTotalThisPeriodString = withdrawalTotalThisPeriod.ToString();
            }

            var model = new KycViewModel
            {
                User     = user,
                LevelNum = levelNum,
                Level    = level,
                WithdrawalTotalThisPeriod = withdrawalTotalThisPeriodString,
                KycSettings      = _kycSettings,
                KycRequestUrl    = kycRequestUrl,
                KycRequestStatus = kycRequestStatus,
            };

            return(View(model));
        }