public static bool TryAddSponsor(SponsorEntry sponsorEntry) { using MySqlConnection c = GetConnection(); c.Open(); MySqlCommand cmd = new MySqlCommand(@"INSERT INTO sponsors (discord_id, github_id) VALUES (@discord_id, @github_id);", c); cmd.Parameters.AddWithValue("@discord_id", sponsorEntry.discordID); cmd.Parameters.AddWithValue("@github_id", sponsorEntry.githubID); int output = cmd.ExecuteNonQuery(); return(output > 0); }
public static bool TryGetSponsor(string githubID, out SponsorEntry sponsorEntry) { using MySqlConnection c = GetConnection(); c.Open(); MySqlCommand selection = new MySqlCommand(@"SELECT * FROM sponsors WHERE github_id=@github_id", c); selection.Parameters.AddWithValue("@github_id", githubID); selection.Prepare(); MySqlDataReader results = selection.ExecuteReader(); if (!results.Read()) { sponsorEntry = new SponsorEntry(); results.Close(); return(false); } sponsorEntry = new SponsorEntry(results); results.Close(); return(true); }