public static Match CreateNewMatch(Team opposition, DateTime matchDay, Venue venue, MatchType type, HomeOrAway homeAway) { var myDao = new Dao(); int id = myDao.CreateNewMatch(opposition.ID, matchDay, venue.ID, (int)type, homeAway); return(new Match(id)); }
public static List <GameResult> ReadSoccerResults(string fileName) { var soccerResults = new List <GameResult>(); using (var reader = new StreamReader(fileName)) { string line = ""; reader.ReadLine(); while ((line = reader.ReadLine()) != null) { var gameResult = new GameResult(); string[] values = line.Split(','); if (DateTime.TryParse(values[0], out DateTime gameDate)) { gameResult.GameDate = gameDate; } gameResult.TeamName = values[1]; if (HomeOrAway.TryParse(values[2], out HomeOrAway homeOrAway)) { gameResult.HomeOrAway = homeOrAway; } if (int.TryParse(values[3], out int parseInt)) { gameResult.Goals = parseInt; } if (int.TryParse(values[4], out parseInt)) { gameResult.GoalAttempts = parseInt; } if (int.TryParse(values[5], out parseInt)) { gameResult.ShotsOnGoal = parseInt; } if (int.TryParse(values[6], out parseInt)) { gameResult.ShotsOffGoal = parseInt; } if (double.TryParse(values[7], out double possessionPercent)) { gameResult.PossessionPercent = possessionPercent; } soccerResults.Add(gameResult); } } return(soccerResults); }
private static PlayerLineup AddPlayersToLineup(HtmlNodeCollection valuesNodes, int round, HomeOrAway homeOrAway, string team) { var playerLineup = new PlayerLineup(); for (int i = 0; i < valuesNodes.Count; i += 11) { playerLineup.Round = round; playerLineup.HomeOrAway = homeOrAway; playerLineup.Team = team; playerLineup.Players.Add( new Player( valuesNodes[i + 2].InnerText, valuesNodes[i].InnerText.TrimEnd('.'), valuesNodes[i + 1].InnerText) ); } var goalies = playerLineup.Players .Where(x => x.PlayerPosition == Position.Målvakt.ToString()) .OrderByDescending(x => x.PlayerNumber).ToList(); foreach (var item in goalies) { playerLineup.Players.Remove(item); playerLineup.Players.Insert(0, item); } return(playerLineup); }