Пример #1
0
        public ActionResult DeletePlayer(int id)
        {
            var playerModelFromRepo = _repository.GetPlayerById(id);

            if (playerModelFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeletePlayer(playerModelFromRepo);
            _repository.SaveChanges();

            return(NoContent());
        }
Пример #2
0
        public IActionResult DeletePlayer(string nbaId)
        {
            var dbPlayer = _playerRepo.GetPlayerNbaId(nbaId);

            if (dbPlayer == null)
            {
                return(BadRequest(ModelState));
            }
            if (!_playerRepo.Exists(dbPlayer))
            {
                ModelState.AddModelError("", $"Player with Id {dbPlayer.NbaId} does not exists");
                return(StatusCode(422, ModelState));
            }
            else
            {
                _playerRepo.DeletePlayer(dbPlayer);
            }
            return(Ok());
        }
Пример #3
0
        public async Task <string> DeletePlayer(Guid playerId)
        {
            await _repo.DeletePlayer(playerId);

            return($"{playerId} has been deleted!");
        }