public int LastOrder(user_controller UserId) { var connect = Connect(); int OrderId = connect.QuerySingleOrDefault <int>("SELECT order_id FROM orders WHERE user_id = @user_id ORDER BY order_id DESC LIMIT 1;", UserId); return(OrderId); }
public int NewOrder(user_controller user) { var connect = Connect(); int NewOrder = connect.Execute("INSERT INTO orders(user_id) VALUES(@user_id)", user); return(NewOrder); }
public bool tryAddUser(user_controller newUser) { string hashedPass = hashPass(newUser.password); newUser.password = hashedPass; var connect = Connect(); connect.Execute(@"INSERT INTO users (email, first_name, last_name, password, username, admin, user_id) VALUES (@email, @first_name, @last_name, @password, @username, @admin, @user_id)" , newUser); return(true); }
public user_controller GetUserByID(int user_id) { var connect = Connect(); List <user_controller> getuser = connect.Query <user_controller>(sql: "SELECT * FROM users").ToList(); foreach (var user in getuser) { if (user.user_id == user_id) { UserByTheirID = user; return(UserByTheirID); } } return(null); }
public user_controller GetUserByUserID(string username) { var connect = Connect(); List <user_controller> usercheckers = connect.Query <user_controller>(sql: "SELECT * FROM users").ToList(); foreach (var user in usercheckers) { if (user.username == username) { UserByID = user; return(UserByID); } } return(null); }