コード例 #1
0
        public async Task <IActionResult> MobileOTPAuthentication([FromBody] MobileOTPDto MobileOTPDto)
        {
            int _returnOTP = 0;

            try
            {
                _returnOTP = await _OTPAuthenticationService.InsertMobileOTPAuthentication(MobileOTPDto);

                try
                {
                    string Message        = _returnOTP + " is your One-Time-Password(OTP) code. code is valid for 2 minutes";
                    string returnmesssage = await _MobileService.SendMobileOTP(MobileOTPDto.Mobilewithcountrycode, Message);

                    if (returnmesssage.Contains("Send Successful"))
                    {
                        return(Ok(new GenericResultDto <string> {
                            Result = "Check your registered Mobile for One-Time-Password(OTP) and enter the code here", OTP = _returnOTP.ToString()
                        }));
                    }
                    else
                    {
                        return(BadRequest(new GenericResultDto <string> {
                            Result = returnmesssage
                        }));
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(new GenericResultDto <string> {
                        Result = ex.Message
                    }));
                }
            }

            catch (Exception err)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = err.Message
                }));
            }
        }
コード例 #2
0
        public async Task <int> InsertMobileOTPAuthentication(MobileOTPDto MobileOTPDto)
        {
            //var varCount = this.Repository.ToList();
            //varCount = varCount.Where(m => m.VerificationId == CustomerRegistrationDto.Email).ToList();
            //if (varCount.Count < 4)
            //{
            Random   random      = new Random();
            int      intOTP      = random.Next(100000, 999999);
            DateTime currentTime = DateTime.Now;
            await Repository.InsertAsync(new OTPAuthentication
            {
                OTP            = intOTP,
                VerificationId = MobileOTPDto.Mobile,
                StartDate      = currentTime,
                EndDate        = currentTime.AddMinutes(10),
            });

            return(intOTP);
            //}
            //return "_" + varCount.Count.ToString();
        }