public ActionResult Details(int id) { try { List <Score> scoresList = new List <Score>(); ScoresDBContext scoresDBContext = new ScoresDBContext(); DataSet dsMatchPlayerScores = new DataSet(); dsMatchPlayerScores = scoresDBContext.GetMatchPlayersScores(id); Matches matches = new Matches(); matches.Location = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Location"]); matches.MatchDate = Convert.ToDateTime(dsMatchPlayerScores.Tables[0].Rows[0]["MatchDate"]); matches.Player1Name = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Player1Name"]); matches.Player2Name = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Player2Name"]); matches.WinnerName = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["WinnerName"]); for (int i = 0; i < dsMatchPlayerScores.Tables[0].Rows.Count; i++) { Score score = new Score(); score.Set1Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set1Score"]); score.Set2Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set2Score"]); score.Set3Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set3Score"]); scoresList.Add(score); } matches.scoreList = scoresList; return(View(matches)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Scores", "Index"))); } }
public Matches getMatchData(int id) { Matches matches = new Matches(); List <Score> scoresList = new List <Score>(); ScoresDBContext scoresDBContext = new ScoresDBContext(); DataSet dsMatchPlayerScores = new DataSet(); dsMatchPlayerScores = scoresDBContext.GetMatchPlayersScores(id); matches.playerNames = getPlayersList(); matches.Location = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Location"]); matches.MatchDate = Convert.ToDateTime(dsMatchPlayerScores.Tables[0].Rows[0]["MatchDate"]); matches.Player1ID = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[0]["Player1ID"]); matches.Player2ID = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[0]["Player2ID"]); matches.WinnerID = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[0]["WinnerID"]); matches.Player1Name = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Player1Name"]); matches.Player2Name = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["Player2Name"]); matches.WinnerName = Convert.ToString(dsMatchPlayerScores.Tables[0].Rows[0]["WinnerName"]); for (int i = 0; i < dsMatchPlayerScores.Tables[0].Rows.Count; i++) { Score score = new Score(); score.Set1Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set1Score"]); score.Set2Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set2Score"]); score.Set3Score = Convert.ToInt32(dsMatchPlayerScores.Tables[0].Rows[i]["Set3Score"]); scoresList.Add(score); } matches.scoreList = scoresList; return(matches); }