コード例 #1
0
 public PlayerExistsValidator(TicTacDbContext context)
 {
     RuleSet("PlayerExistingSet", () =>
     {
         //RuleFor(x => x.UserName)
         //.MustAsync(
         //    async (o, s, token) =>
         //    await context.Player.AnyAsync(c => c.UserName == s));
     });
 }
コード例 #2
0
        /// <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");
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public CreateNewPlayerHandler(TicTacDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
コード例 #5
0
 public CreateDatabaseHandler(TicTacDbContext context)
 {
     _context = context;
 }
コード例 #6
0
 public AddNewStepHandler(TicTacDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
コード例 #7
0
 public GetGameHandler(TicTacDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
コード例 #8
0
 public GetAllPlayersHandler(IMapper mapper, TicTacDbContext context)
 {
     _mapper  = mapper;
     _context = context;
 }