public ActionResult DeletePlayer(int id) { var playerModelFromRepo = _repository.GetPlayerById(id); if (playerModelFromRepo == null) { return(NotFound()); } _repository.DeletePlayer(playerModelFromRepo); _repository.SaveChanges(); return(NoContent()); }
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()); }
public async Task <string> DeletePlayer(Guid playerId) { await _repo.DeletePlayer(playerId); return($"{playerId} has been deleted!"); }