public bool OTPSenderUser(string phone) { TwilioClient.Init(Constant.accountSid, Constant.authToken); int otp = GenerationOTP.GenerationRandomOTP(); // check phone exist in db var entity = db.Users.FirstOrDefault(item => item.user_phone == phone); if (entity != null) { entity.user_otp = otp.ToString(); db.SaveChanges(); // create new password send user // Send a text message MessageResource.Create( body: otp.ToString() + Constant.OPTMessage, from: new Twilio.Types.PhoneNumber(Constant.contactSystems), to: new Twilio.Types.PhoneNumber(Constant.contactCustomer) ); return(true); } else { return(false); } }
// send otp when payment credit cart public bool PaymentByCreditCard(Cart cart) { TwilioClient.Init(Constant.accountSid, Constant.authToken); int otp = GenerationOTP.GenerationRandomOTP(); var entity = db.Users.Find(Int32.Parse(cart.UserId)); if (entity != null) { entity.user_otp = otp.ToString(); db.SaveChanges(); MessageResource.Create( body: otp.ToString() + Constant.OPTMessage, from: new Twilio.Types.PhoneNumber(Constant.contactSystems), to: new Twilio.Types.PhoneNumber(Constant.contactCustomer) ); return(true); } return(false); }