Add count function to rafflerepository
This commit is contained in:
parent
0a6dab9cf5
commit
fcd3c04ebb
@ -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<string, object> filterDict = new Dictionary<string, object>();
|
||||
filterDict.Add("userId", userId);
|
||||
|
||||
DataTable dataTable = Controller.SelectQuery(Table, "COUNT(*)", filterDict);
|
||||
|
||||
return Convert.ToInt32(dataTable.Rows[0]["COUNT(*)"]);
|
||||
}
|
||||
|
||||
public static Raffle[] selectUser(string userId)
|
||||
|
||||
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user