public JsonResult StoreOtp(string number) { string user = _userContext.GetUserByNumber(number); if (user != null) { Random generator = new Random(); string otp = generator.Next(0, 999999).ToString("D6"); string msgId = SendSms(number, "OTP :- " + otp + " it will expire in 10 minutes"); if (msgId != null || msgId != "") { //string MsgId = generator.Next(0, 999999).ToString(); _userContext.UpdateOtp(number, msgId); _otpContext.StoreOtp(new OtpModel { MsgId = msgId, Otp = otp }); return(Json(new { status = true, data = msgId, message = "Otp Sent !!" })); } else { return(Json(new { status = false, message = "Enter Valid Number please !!" })); } } else { return(Json(new { status = false, message = "You are not registered ,firstly Register yourself !!" })); } }