Esempio n. 1
0
        public Task AddShot(GameDomainModel game, ShotDomainModel shot, ShipDomainModel ship = null)
        {
            ShotEntity shotEntity = new ShotEntity
            {
                ShipId = ship?.Id,
                GameId = game.Id,
                X      = shot.Point.X,
                Y      = shot.Point.Y
            };

            _context.Shots.Add(shotEntity);

            return(_context.SaveChangesAsync());
        }
Esempio n. 2
0
        public async Task <ShotDomainModel> TryGetShot(GameDomainModel game, int x, int y)
        {
            ShotEntity entity = await _context.Shots
                                .Where(shot => shot.GameId == game.Id)
                                .Where(shot => shot.X == x)
                                .Where(shot => shot.Y == y)
                                .OrderBy(shot => shot.Id)
                                .AsNoTracking()
                                .FirstOrDefaultAsync();

            if (entity is null)
            {
                return(null);
            }

            return(new ShotDomainModel(new Point(entity.X, entity.Y)));
        }