public PlayerExistsValidator(TicTacDbContext context) { RuleSet("PlayerExistingSet", () => { //RuleFor(x => x.UserName) //.MustAsync( // async (o, s, token) => // await context.Player.AnyAsync(c => c.UserName == s)); }); }
/// <summary> /// Check for the existence of players in the database. /// </summary> private static async Task CheckPlayerIdForExistenceAsync( TicTacDbContext context, string id, CancellationToken cancellationToken) { var haunterOne = await context.Haunters .Where(p => p.Id == id) .FirstOrDefaultAsync(cancellationToken); if (haunterOne != null) { return; } Result.Fail <Game>($"There is no player's id {id} in database"); }
private static (string One, string Two) GetPlayers( TicTacDbContext context, int id) { var playerOne = context.Players .Where(c => c.GameId == id) .Select(s => s.FirstPlayer) .Select(x => x.HaunterId) .FirstOrDefaultAsync() .Result; var playerTwo = context.Players .Where(c => c.GameId == id) .Select(s => s.SecondPlayer) .Select(x => x.HaunterId) .FirstOrDefaultAsync() .Result; return(playerOne, playerTwo); }
public CreateNewPlayerHandler(TicTacDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public CreateDatabaseHandler(TicTacDbContext context) { _context = context; }
public AddNewStepHandler(TicTacDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetGameHandler(TicTacDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetAllPlayersHandler(IMapper mapper, TicTacDbContext context) { _mapper = mapper; _context = context; }