public ActionResult NewUser(Users model) { try { Accountservice User = new Accountservice(); Tuple <byte[], byte[]> password = User.Generatepass(model.Password); postgres sql = new postgres(); // Behöver skrivas om sql.SqlNonQuery("INSERT INTO login (salt, key ,username,roles_id,email,acc_active,last_login) VALUES (@par2,@par3,@par1,'2',@email,@active,@last_login)", postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@par1", model.User), new NpgsqlParameter("@par2", password.Item1), new NpgsqlParameter("@email", model.email), new NpgsqlParameter("@active", model.active), new NpgsqlParameter("@last_login", DateTime.Now), new NpgsqlParameter("@par3", password.Item2) }); return(RedirectToAction("index", "admin")); } catch { return(View()); } }
public void CreateUser(string user, string email, bool active, string Password, string fname, string last_name) { Accountservice User = new Accountservice(); Tuple <byte[], byte[]> password = User.Generatepass(Password); postgres sql = new postgres(); // Behöver skrivas om! klart! postgres sql2 = new postgres(); int id = sql2.SqlQueryString("INSERT INTO login (salt, hash, reset_time, reset_hash) VALUES (@salt ,@hash, @time, 1) RETURNING login_id;", postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@salt", password.Item1), new NpgsqlParameter("@hash", password.Item2), new NpgsqlParameter("@time", Convert.ToDateTime("1970-01-01 00:00:00")) }); postgres sql3 = new postgres(); int id_setting = sql3.SqlQueryString("INSERT INTO usersettings (day_of_slumpcron) VALUES (6) RETURNING setting_id;", postgres.list = new List <NpgsqlParameter>() { }); sql.SqlNonQuery("INSERT INTO users (username,roles_id,email,acc_active,last_login,login_id,settings_id,fname,last_name) VALUES (@par1,'2',@email,@active,@last_login,@login_id,@settings_id,@fname,@last_name)", postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@par1", user), new NpgsqlParameter("@email", email), new NpgsqlParameter("@active", active), new NpgsqlParameter("@login_id", id), new NpgsqlParameter("@settings_id", id_setting), new NpgsqlParameter("@last_login", DateTime.Now), new NpgsqlParameter("@fname", fname), new NpgsqlParameter("@last_name", last_name) }); }
public void Newpassword(int login_id, string newpassword) { Accountservice User1 = new Accountservice(); Tuple <byte[], byte[]> password = User1.Generatepass(newpassword); postgres sql = new postgres(); // behöver skrivas om! klart sql.SqlNonQuery("UPDATE login set salt= @par2, hash =@par3 WHERE login_id =@par1", postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@par1", login_id), new NpgsqlParameter("@par2", password.Item1), new NpgsqlParameter("@par3", password.Item2) }); }
public void UpdateUser(int User_id, string username, string email, string first_name, string last_name, int Slumpday) { postgres sql = new postgres(); //Behöver skrivas OM! klar sql.SqlNonQuery("Select update_user(@username,@email,@first_name,@lastname,@cronoday,@user_id)", postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@username", username), new NpgsqlParameter("@email", email), new NpgsqlParameter("@first_name", first_name), new NpgsqlParameter("@lastname", last_name), new NpgsqlParameter("@cronoday", Slumpday), new NpgsqlParameter("@user_id", User_id) }); }
public void SaveSlump(int recept_id, int user_id, DateTime date, bool check) { string sql = "INSERT INTO foodlist (user_id,recept_id,date_now) values(@user_id,@recept_id,@date_now)"; if (check) { sql = "UPDATE foodlist SET recept_id = @recept_id WHERE date_now=@date_now AND user_id = @user_id"; } postgres m = new postgres(); m.SqlNonQuery(sql, postgres.list = new List <NpgsqlParameter>() { new NpgsqlParameter("@recept_id", recept_id), new NpgsqlParameter("@date_now", date), new NpgsqlParameter("@user_id", user_id) }); }