Ejemplo n.º 1
0
 private async Task<ResponseResult> GetOTPResult(string PhoneNumber, string Reference)
 {
     return await Task.Run(() =>
     {
         while (true)
         {
             using (var db = new Entities())
             {
                 var OTPModel = db.OTPs.Where(x => x.To == PhoneNumber && x.Ref == Reference && x.Passed == false).FirstOrDefault();
                 if (OTPModel != null && !string.IsNullOrWhiteSpace(OTPModel.Result))
                 {
                     OTPModel.Passed = true;
                     db.Entry(OTPModel).State = EntityState.Modified;
                     db.SaveChanges();
                     ResponseResult ResponseResult = new ResponseResult()
                     {
                         Status = ResponseStatusEnum.Successful,
                         Data = OTPModel.Result
                     };
                     return ResponseResult;
                 }
                 Task.Delay(1000);
             }
         }
     });
 }
Ejemplo n.º 2
0
 private async Task<ResponseResult> GetCaptChaResult(int Id)
 {
     return await Task.Run(() =>
     {
         while (true)
         {
             using (var db = new Entities())
             {
                 var captchaModel = db.Captchas.Where(x => x.Id == Id).FirstOrDefault();
                 if (captchaModel != null && !string.IsNullOrWhiteSpace(captchaModel.Result))
                 {
                     captchaModel.Passed = true;
                     db.Entry(captchaModel).State = EntityState.Modified;
                     db.SaveChanges();
                     ResponseResult captchaResult = new ResponseResult()
                     {
                         Status = ResponseStatusEnum.Successful,
                         Data = captchaModel.Result
                     };
                     return captchaResult;
                 }
                 Task.Delay(1000);
             }
         }
     });
 }