Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        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());
        }