public async static Task <int> AddPremium(ulong userId, ProType type, ulong guildId = 0, DateTime?expiresAt = null) { if (expiresAt == null) { expiresAt = DateTime.Now.AddMonths(1); } using var db = new NamikoDbContext(); db.Premiums.Add(new Premium { GuildId = guildId, UserId = userId, Type = type, ClaimDate = System.DateTime.Now, ExpiresAt = expiresAt.Value, ExpireSent = false }); return(await db.SaveChangesAsync()); }
public static bool IsPremium(ulong Id, ProType type) { using var db = new NamikoDbContext(); return(db.Premiums.Any(x => x.Type == type && (x.GuildId == Id || x.UserId == Id) && x.ExpiresAt > DateTime.Now)); }
public static async Task <List <WaifuWish> > GetAllPremiumWishlists(ulong guildId, ProType premium) { using var db = new NamikoDbContext(); var users = db.Premiums.Where(x => x.Type == premium).Select(x => x.UserId); var wishlists = db.WaifuWishlist.Where(x => x.GuildId == guildId && users.Contains(x.UserId)).Include(x => x.Waifu); return(await wishlists.ToListAsync()); }