public async Task <Unit> Handle(DeleteGameConsole request, CancellationToken cancellationToken)
        {
            var system = _store.GameConsoles.Single(s => s.Id == request.SystemId);

            _store.Remove(system);

            await _store.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(DeleteGame request, CancellationToken cancellationToken)
        {
            ///TODO: Unit testing point! We shouldn't be able to delete a game if copies exist
            var game = _context.Games.Single(gt => gt.Id == request.GameId);

            _context.Remove(game);

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <IActionResult> Delete(int id)
        {
            var system = await _gamesContext.Systems.FindAsync(id);

            if (system == null)
            {
                return(NotFound());
            }

            _gamesContext.Remove(system);
            await _gamesContext.SaveChangesAsync();

            return(NoContent());
        }
Exemple #4
0
        public void ContextRemovesAGame()
        {
            var game = new Game {
                Name = "Game 2"
            };
            var mockGameRepository = new MockGameRepository().StubGetByToReturn(game);
            var mockGameMapper     = new MockGameMapper();
            var gamesContext       = new GamesContext(mockGameRepository, mockGameMapper);

            gamesContext.Remove(game.Id);

            mockGameRepository.VerifyGetByCalledWith(game.Id);
            mockGameRepository.VerifyRemoveCalledWith(game);
        }