public Task <User> GetUserAsync(int id, User.ControlFlags flags) => ConnectAsync(_connectionString, async connection => { var command = new MySqlCommand($@"{ReusableQueries.GetUsersSql} WHERE id = @id LIMIT 1", connection); command.Parameters.AddWithValue("@id", id); var bets = flags.HasFlag(User.ControlFlags.Bets) ? await ListBetsAsync(id) : new List <UserBet>(); return(await command.QueryOneAsync(reader => reader.MapToUser(bets))); });
public Task <User> GetUserAsync(string username, User.ControlFlags flags) => ConnectAsync(_connectionString, async connection => { var command = new MySqlCommand($@"{ReusableQueries.GetUsersSql} WHERE username = @username LIMIT 1", connection); command.Parameters.AddWithValue("@username", username); var user = await command.QueryOneAsync(reader => reader.MapToUser()); if (user == null) { return(null); } user.Bets = flags.HasFlag(User.ControlFlags.Bets) ? await ListBetsAsync(user.Id) : new List <UserBet>(); return(user); });