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