public async Task <ActionResult> TrackPlayer(NbaPlayer player) { _playersFollowedDataAccessor.AddPlayerForUser(1, player); var trackerViewModel = await _nbaPlayerTrackerModelBuilder.BuildPlayerTrackerViewModel(1); return(View("PlayerTracker", trackerViewModel)); }
public ActionResult <NbaPlayer> Put(NbaPlayer nbaPlayer) { _nbaPlayer.Update(nbaPlayer); _nbaPlayer.Save(); return(Ok(nbaPlayer)); }
public ActionResult <NbaPlayer> Post(NbaPlayer nbaPlayer) { _nbaPlayer.Create(nbaPlayer); _nbaPlayer.Save(); return(Ok(nbaPlayer)); }
public List <NbaPlayer> GetPlayers(Guid gameId, string side) { // Allowable values of parameter side are "home" or "away" List <NbaPlayer> playerList = new List <NbaPlayer>(); using (MySqlConnection mySqlConnection = MySqlConnection) { mySqlConnection.Open(); const string storedProcedure = "pbp.GetPlayers"; using (MySqlCommand mySqlCommand = new MySqlCommand(storedProcedure, mySqlConnection)) { mySqlCommand.CommandType = CommandType.StoredProcedure; MySqlParameter mySqlParameter1 = new MySqlParameter(nameof(gameId), gameId); mySqlCommand.Parameters.Add(mySqlParameter1); MySqlParameter mySqlParameter2 = new MySqlParameter(nameof(side), side); mySqlCommand.Parameters.Add(mySqlParameter2); using (MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader()) { if (!mySqlDataReader.HasRows) { const string error = "GetPlayers() has no rows"; string message = $"{error,50}: {storedProcedure,40}, {gameId,40}, {side}\n"; Write(message); return(playerList); } int playerNumber = 1; while (mySqlDataReader.Read()) { NbaPlayer nbaPlayer = new NbaPlayer { GameId = mySqlDataReader.GetGuid("game_id"), PlayerId = mySqlDataReader.GetGuid("player_id"), FullName = mySqlDataReader.GetString("full_name"), JerseyNumber = mySqlDataReader.GetInt32("jersey"), TeamId = mySqlDataReader.GetGuid("team_id"), Side = side, Number = playerNumber }; playerNumber++; playerList.Add(nbaPlayer); } return(playerList); } } } }
public void Update(NbaPlayer nbaPlayer) { _context.NbaPlayers.Update(nbaPlayer); }
public void Delete(NbaPlayer nbaPlayer) { _context.NbaPlayers.Remove(nbaPlayer); }
public void Create(NbaPlayer nbaPlayer) { _context.NbaPlayers.Add(nbaPlayer); }