//public string createtoken(string mobileno) //{ // string encryptedstring = ""; // using (GrowIndigoAPIDBEntities dbContext = new GrowIndigoAPIDBEntities()) // { // var Otp = dbContext.UserOTPInfo.Where(x => x.MobileNumber == mobileno).OrderBy(x => x.GenratedDate).Select(x => x.OTP).FirstOrDefault(); // if (Otp != "") // { // var token = mobileno + "/" + Otp; // encryptedstring = encrypt(token); // } // return encryptedstring; // } //} public bool verifytoken(string token) { string decryptedtoken = ""; try { using (GrowIndigoAPIDBEntities dbContext = new GrowIndigoAPIDBEntities()) { decryptedtoken = Decrypt(token); var res = decryptedtoken.Split('/'); if (res != null) { string mobileno = res[0] != null ? res[0] : ""; string otp = res[1] != null ? res[1] : ""; var user = dbContext.UserOTPInfo.Where(x => x.MobileNumber == mobileno && x.OTP == otp).FirstOrDefault(); if (user != null) { return(true); } } } } catch (Exception ex) { return(false); } return(false); }