public ActionResult SignUp(UserData data)
        {
            entity = new LoginAndSignupEntities();
            if (data != null)
            {
                entity.UserData.Add(data);
                entity.SaveChanges();
            }

            return(RedirectToAction("SendOTP", "LogInAndSignUp"));
        }
        // Post: LogInAndSignUp
        public ActionResult SignIn(OTP otp)
        {
            ViewBag.Message = null;
            entity          = new LoginAndSignupEntities();
            if (otp == null || otp.OneTimePassword.ToString() != _otp.ToString())
            {
                return(RedirectToAction("SignIn", "LogInAndSignUp"));
            }

            else if (_isRegistered)
            {
                Session["Mobile"] = PhoneNumber.ToString();
                return(RedirectToAction("WelcomePage", "LogInAndSignUp"));
            }

            return(RedirectToAction("SignUp", "LogInAndSignUp"));
        }
        public ActionResult SendOTP(MobileNumber phone)
        {
            ViewBag.Message = null;

            entity = new LoginAndSignupEntities();

            _isRegistered = entity.UserData.Any(x => x.MobileNumber.ToString() == phone.PhoneNumber.ToString());
            if (phone.PhoneNumber.ToString().Length != 10)
            {
                ViewBag.Message = "Incorrect Mobile number. Enter again";
                return(RedirectToAction("SendOTP", "LogInAndSignUp"));
            }

            PhoneNumber = phone.PhoneNumber.ToString();
            _otp        = _random.Next(100000, 999999);
            SendOtp();
            return(RedirectToAction("SignIn", "LogInAndSignUp"));
        }