Patreon id logic change

This commit is contained in:
Master Kwoth
2017-05-02 10:52:15 +02:00
parent 8b320ef0c1
commit 3ff989cf92
5 changed files with 1586 additions and 1 deletions

View File

@@ -173,13 +173,14 @@ namespace NadekoBot.Modules.Utility
using (var uow = DbHandler.UnitOfWork())
{
var users = uow._context.Set<RewardedUser>();
var usr = users.FirstOrDefault(x => x.UserId == userId);
var usr = users.FirstOrDefault(x => x.PatreonUserId == data.User.id);
if (usr == null)
{
users.Add(new RewardedUser()
{
UserId = userId,
PatreonUserId = data.User.id,
LastReward = now,
AmountRewardedThisMonth = amount,
});
@@ -194,6 +195,7 @@ namespace NadekoBot.Modules.Utility
{
usr.LastReward = now;
usr.AmountRewardedThisMonth = amount;
usr.PatreonUserId = data.User.id;
await CurrencyHandler.AddCurrencyAsync(userId, "Patreon reward - recurring", amount, uow).ConfigureAwait(false);
@@ -207,6 +209,7 @@ namespace NadekoBot.Modules.Utility
usr.LastReward = now;
usr.AmountRewardedThisMonth = amount;
usr.PatreonUserId = data.User.id;
await CurrencyHandler.AddCurrencyAsync(usr.UserId, "Patreon reward - update", toAward, uow).ConfigureAwait(false);