Example #1
0
        private async Task <Response> GetRegistCodeAsync()
        {
            var exist = await _verificationCodeService.ExistAvailableRegistCodeByClientIpAsync(ClientIP).ConfigureAwait(false);

            if (exist)
            {
                return(Ok(new { code = await _verificationCodeService.GetAvailableRegistCodeByClientIpAsync(ClientIP).ConfigureAwait(false) }));
            }
            else
            {
                var help   = VerifyCodeHelper.GetSingleObj();
                var code   = help.CreateVerifyCode(VerifyCodeHelper.VerifyCodeType.MixVerifyCode);
                var entity = new VerificationCode
                {
                    Code       = code,
                    Type       = CodeType.Regist,
                    CreatedOn  = DateTime.Now,
                    IsDisabled = false,
                    ClientIp   = ClientIP
                };
                await _verificationCodeService.NewVerificationCodeAsync(entity).ConfigureAwait(false);

                return(Ok(new { code = code }));
            }
        }