Esempio n. 1
0
        public static async Task <bool> AddParticipant(ulong userId, Banroulette banroulette)
        {
            using var db = new NamikoDbContext();
            if (db.BanrouletteParticipants.Count(x => x.UserId == userId && x.Banroulette.Id == banroulette.Id) > 0)
            {
                return(false);
            }

            db.Update(new BanrouletteParticipant {
                Banroulette = banroulette, UserId = userId
            });

            if (await db.SaveChangesAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
 public static async Task NewBanroulette(Banroulette banroulette)
 {
     using var db = new NamikoDbContext();
     db.Add(banroulette);
     await db.SaveChangesAsync();
 }
Esempio n. 3
0
 public static bool IsParticipant(Banroulette banroulette, ulong userId)
 {
     using var db = new NamikoDbContext();
     return(db.BanrouletteParticipants.Any(x => x.Banroulette.Id == banroulette.Id && userId == x.UserId));
 }
Esempio n. 4
0
 public static List <ulong> GetParticipants(Banroulette banroulette)
 {
     using var db = new NamikoDbContext();
     return(db.BanrouletteParticipants.Where(x => x.Banroulette.Id == banroulette.Id).Select(x => x.UserId).ToList());
 }