示例#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);
        }
示例#2
0
 public static async Task NewBanroulette(Banroulette banroulette)
 {
     using var db = new NamikoDbContext();
     db.Add(banroulette);
     await db.SaveChangesAsync();
 }
示例#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));
 }
示例#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());
 }