public ActionResult CreateAccount(string username, string password, string firstName, string surname) { var account = new AccountManager(); var user = new User(username, password, firstName, surname); account.CreateNewUserAccount(user); //var createdAccountModel = new CreatedAccountModel(userAccount, "Successfully Created"); return View("Index"); }
public void CreateNewUserAccount(User user) { using ( var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DbConnectionString"].ConnectionString)) { connection.Open(); var insertCmdText = "INSERT INTO Users (Username, Password, Firstname, Surname) OUTPUT Inserted.Username VALUES ('{0}', '{1}', '{2}', '{3}')"; insertCmdText = string.Format(insertCmdText, user.Username, user.Password, user.Firstname, user.Surname); var addUser = new SqlCommand(insertCmdText, connection); addUser.ExecuteNonQuery(); //var val = addUser.ExecuteScalar(); //return (User)val; } }