示例#1
0
 public static void RegisterUser(RegisterModel model)
 {
     DataLayer.RegisterUser(model);
 }
示例#2
0
        public static void RegisterUser(RegisterModel model)
        {
            using (SqlConnection dbCon = ConnectToDb(DBConnString))
            {

                SqlCommand cmdGetDetailsByCompanyName = new SqlCommand();
                cmdGetDetailsByCompanyName.Connection = dbCon;
                cmdGetDetailsByCompanyName.CommandType = System.Data.CommandType.StoredProcedure;
                cmdGetDetailsByCompanyName.CommandText = "usp_AddUser";

                SqlParameter paramUserName = new SqlParameter("UserName", model.UserName);
                SqlParameter paramPassword = new SqlParameter("Password", model.Password);
                SqlParameter paramEmail = new SqlParameter("EmailId", model.EmailID);

                cmdGetDetailsByCompanyName.Parameters.Add(paramUserName);
                cmdGetDetailsByCompanyName.Parameters.Add(paramPassword);
                cmdGetDetailsByCompanyName.Parameters.Add(paramEmail);

                //var parms = new IDataParameter[3];
                //int i = 0;
                //parms[i++] = NewParameter("UserName", SqlDbType.VarChar, model.UserName);
                //parms[i++] = NewParameter("Password", SqlDbType.VarChar, model.Password);
                //parms[i++] = NewParameter("EmailId", SqlDbType.VarChar, model.EmailID);

                //cmdGetDetailsByCompanyName.Parameters.Add(parms);

                var i = cmdGetDetailsByCompanyName.ExecuteNonQuery();

            }
        }
示例#3
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }