Patreon id logic change
This commit is contained in:
parent
8b320ef0c1
commit
3ff989cf92
1555
src/NadekoBot/Migrations/20170501103455_patreon-id.Designer.cs
generated
Normal file
1555
src/NadekoBot/Migrations/20170501103455_patreon-id.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
src/NadekoBot/Migrations/20170501103455_patreon-id.cs
Normal file
24
src/NadekoBot/Migrations/20170501103455_patreon-id.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace NadekoBot.Migrations
|
||||||
|
{
|
||||||
|
public partial class patreonid : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PatreonUserId",
|
||||||
|
table: "RewardedUsers",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PatreonUserId",
|
||||||
|
table: "RewardedUsers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -966,6 +966,8 @@ namespace NadekoBot.Migrations
|
|||||||
|
|
||||||
b.Property<DateTime>("LastReward");
|
b.Property<DateTime>("LastReward");
|
||||||
|
|
||||||
|
b.Property<string>("PatreonUserId");
|
||||||
|
|
||||||
b.Property<ulong>("UserId");
|
b.Property<ulong>("UserId");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
@ -173,13 +173,14 @@ namespace NadekoBot.Modules.Utility
|
|||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var users = uow._context.Set<RewardedUser>();
|
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)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
users.Add(new RewardedUser()
|
users.Add(new RewardedUser()
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
|
PatreonUserId = data.User.id,
|
||||||
LastReward = now,
|
LastReward = now,
|
||||||
AmountRewardedThisMonth = amount,
|
AmountRewardedThisMonth = amount,
|
||||||
});
|
});
|
||||||
@ -194,6 +195,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
{
|
{
|
||||||
usr.LastReward = now;
|
usr.LastReward = now;
|
||||||
usr.AmountRewardedThisMonth = amount;
|
usr.AmountRewardedThisMonth = amount;
|
||||||
|
usr.PatreonUserId = data.User.id;
|
||||||
|
|
||||||
await CurrencyHandler.AddCurrencyAsync(userId, "Patreon reward - recurring", amount, uow).ConfigureAwait(false);
|
await CurrencyHandler.AddCurrencyAsync(userId, "Patreon reward - recurring", amount, uow).ConfigureAwait(false);
|
||||||
|
|
||||||
@ -207,6 +209,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
usr.LastReward = now;
|
usr.LastReward = now;
|
||||||
usr.AmountRewardedThisMonth = amount;
|
usr.AmountRewardedThisMonth = amount;
|
||||||
|
usr.PatreonUserId = data.User.id;
|
||||||
|
|
||||||
await CurrencyHandler.AddCurrencyAsync(usr.UserId, "Patreon reward - update", toAward, uow).ConfigureAwait(false);
|
await CurrencyHandler.AddCurrencyAsync(usr.UserId, "Patreon reward - update", toAward, uow).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace NadekoBot.Services.Database.Models
|
|||||||
public class RewardedUser : DbEntity
|
public class RewardedUser : DbEntity
|
||||||
{
|
{
|
||||||
public ulong UserId { get; set; }
|
public ulong UserId { get; set; }
|
||||||
|
public string PatreonUserId { get; set; }
|
||||||
public int AmountRewardedThisMonth { get; set; }
|
public int AmountRewardedThisMonth { get; set; }
|
||||||
public DateTime LastReward { get; set; }
|
public DateTime LastReward { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user