diff --git a/ChaosBot/Database/Repository/RaffleRepository.cs b/ChaosBot/Database/Repository/RaffleRepository.cs index ed6d2da..dab4711 100644 --- a/ChaosBot/Database/Repository/RaffleRepository.cs +++ b/ChaosBot/Database/Repository/RaffleRepository.cs @@ -24,6 +24,23 @@ namespace ChaosBot.Database.Repository } return raffles.ToArray(); + } + + public static int count() + { + DataTable dataTable = Controller.SelectQuery(Table, "COUNT(*)"); + + return Convert.ToInt32(dataTable.Rows[0]["COUNT(*)"]); + } + + public static int count(string userId) + { + Dictionary filterDict = new Dictionary(); + filterDict.Add("userId", userId); + + DataTable dataTable = Controller.SelectQuery(Table, "COUNT(*)", filterDict); + + return Convert.ToInt32(dataTable.Rows[0]["COUNT(*)"]); } public static Raffle[] selectUser(string userId) diff --git a/ChaosBot/Discord/Modules/RaffleSystem.cs b/ChaosBot/Discord/Modules/RaffleSystem.cs index b2cec50..e0e62f7 100644 --- a/ChaosBot/Discord/Modules/RaffleSystem.cs +++ b/ChaosBot/Discord/Modules/RaffleSystem.cs @@ -156,7 +156,7 @@ namespace ChaosBot.Discord.Modules sb.AppendLine($"{Context.User.Mention} has added {amount} rafflepoints to <@{userId}>."); sb.AppendLine(); - sb.AppendLine($"<@{userId}> now has {RaffleRepository.selectUser(userId.ToString()).Length} rafflepoints!"); + sb.AppendLine($"<@{userId}> now has {RaffleRepository.count(userId.ToString())} rafflepoints!"); } private void PickRaffle(StringBuilder sb) @@ -178,8 +178,8 @@ namespace ChaosBot.Discord.Modules { ulong userId = Convert.ToUInt64(user.Substring(3, user.Length-4)); - sb.AppendLine($"<@{userId}>, you have {RaffleRepository.selectUser(userId.ToString()).Length} rafflepoints."); - sb.AppendLine($"There is a total of {RaffleRepository.all().Length} rafflepoints."); + sb.AppendLine($"<@{userId}>, you have {RaffleRepository.count(userId.ToString())} rafflepoints."); + sb.AppendLine($"There is a total of {RaffleRepository.count()} rafflepoints."); } } } \ No newline at end of file