public ActionResult Create(StaffRegistrationModel staffRegistrationModel)
        {
            DB dbConn = new DB();

            // String connectionString = @"server=localhost;port=3306;user id=root;database=mas_isscs;password=ThirtyFirst9731@;";

            using (MySqlConnection mySqlCon = dbConn.DBConnection())
            {
                mySqlCon.Open();
                String       qry      = "INSERT INTO users(UserName,UserEmail,UserMobile,Password,ConfirmPassword,UserDepartment,UserType) VALUES(@UserName,@UserEmail,@UserMobile,@Password,@ConfirmPassword,@UserDepartment,@UserType)";
                MySqlCommand mySqlcmd = new MySqlCommand(qry, mySqlCon);

                mySqlcmd.Parameters.AddWithValue("@UserName", staffRegistrationModel.UserFullName);
                mySqlcmd.Parameters.AddWithValue("@UserEmail", staffRegistrationModel.UserEmail);
                mySqlcmd.Parameters.AddWithValue("@UserMobile", staffRegistrationModel.UserMobile);
                mySqlcmd.Parameters.AddWithValue("@Password", staffRegistrationModel.Password);
                mySqlcmd.Parameters.AddWithValue("@ConfirmPassword", staffRegistrationModel.ConfirmPassword);
                mySqlcmd.Parameters.AddWithValue("@UserDepartment", staffRegistrationModel.UserDepartment);
                mySqlcmd.Parameters.AddWithValue("@UserType", staffRegistrationModel.UserType);

                mySqlcmd.ExecuteNonQuery();
            }

            return(RedirectToAction("Create"));
        }
        public ActionResult Create(StaffRegistrationModel userRegistrationModel)
        {
            DB dbConn = new DB();

            // String connectionString = @"server=localhost;port=3306;user id=root;database=mas_isscs;password=ThirtyFirst9731@;";

            using (MySqlConnection mySqlCon = dbConn.DBConnection())
            {
                mySqlCon.Open();
                String       qry      = "INSERT INTO users(UserName,UserEmail,UserMobile,Password,ConfirmPassword,UserDepartment,UserType,SecretKey,Validation,UserImage) VALUES(@UserName,@UserEmail,@UserMobile,@Password,@ConfirmPassword,@UserDepartment,@UserType,@SecretKey,@Validation,@UserImage)";
                MySqlCommand mySqlcmd = new MySqlCommand(qry, mySqlCon);



                mySqlcmd.Parameters.AddWithValue("@UserName", userRegistrationModel.UserFullName);
                mySqlcmd.Parameters.AddWithValue("@UserEmail", userRegistrationModel.UserEmail);
                mySqlcmd.Parameters.AddWithValue("@UserMobile", userRegistrationModel.UserMobile);
                mySqlcmd.Parameters.AddWithValue("@Password", userRegistrationModel.Password);
                mySqlcmd.Parameters.AddWithValue("@ConfirmPassword", userRegistrationModel.ConfirmPassword);
                mySqlcmd.Parameters.AddWithValue("@UserDepartment", userRegistrationModel.UserDepartment);
                mySqlcmd.Parameters.AddWithValue("@UserType", userRegistrationModel.UserType);
                mySqlcmd.Parameters.AddWithValue("@UserImage", "NULL");

                Session["forgotEmail"]  = userRegistrationModel.UserEmail;
                Session["forgotMobile"] = Convert.ToInt32(userRegistrationModel.UserMobile);

                int mobileDigists = Convert.ToInt32(userRegistrationModel.UserMobile) % 10000;
                userRegistrationModel.SecretKey = mobileDigists + Convert.ToInt32(DateTime.Now.ToString("yymmssfff"));

                mySqlcmd.Parameters.AddWithValue("@SecretKey", userRegistrationModel.SecretKey);
                mySqlcmd.Parameters.AddWithValue("@Validation", "false");

                string UserName = "******"; //acount username
                string Password = "******";       //account password
                string PhoneNo  = "94" + userRegistrationModel.UserMobile.ToString();
                string Message  = "Hello " + userRegistrationModel.UserFullName + ". Welcome to MAS IMS.Your Security Code : " + userRegistrationModel.SecretKey.ToString();

                string       url      = @"http://api.liyanagegroup.com/sms_api.php?sms=" + @Message + "&to=" + @PhoneNo + "&usr="******"&pw=" + @Password;
                WebRequest   request  = HttpWebRequest.Create(url);
                WebResponse  response = request.GetResponse();
                StreamReader reader   = new StreamReader(response.GetResponseStream());

                string urlText = reader.ReadToEnd(); //it takes the response from your url. now you can use as your need

                if (urlText == "OK")
                {
                    Response.Write("SMS Sent..!");
                }
                else
                {
                    Response.Write("SMS Sent Fail.!");
                }

                mySqlcmd.ExecuteNonQuery();
            }

            return(RedirectToAction("SecureCode", "UserRegistration"));
        }
Exemplo n.º 3
0
 internal MySqlConnection DBConnection(StaffRegistrationModel staffRegistrationModel1, object staffRegistrationModel2)
 {
     throw new NotImplementedException();
 }