/// <summary> /// Delete a player match /// </summary> /// <param name="playerMatch"></param> public void DeletePlayerMatch(PlayerMatch playerMatch) { GlobalVariables.XmlData.Descendants("players_matches").Elements("player_match").Where(item => (item.Element("playerId").Value.Equals(playerMatch.PlayerID) && item.Element("matchId").Value.Equals(playerMatch.MatchID))).Remove(); GlobalVariables.XmlData.Save(HttpContext.Current.Server.MapPath(GlobalVariables.XmlPath)); GlobalVariables.Update(); }
/// <summary> /// Contructor to get all matches from xml file and save them to allPlayerMatches List /// </summary> public PlayerMatchRepository() { allPlayerMatches = new List <PlayerMatch>(); var PlayerMatches = from PlayerMatch in GlobalVariables.XmlData.Descendants("player_match") select new PlayerMatch(PlayerMatch.Element("playerId").Value, PlayerMatch.Element("matchId").Value, (int)PlayerMatch.Element("noOfGoals"), (int)PlayerMatch.Element("noOfYellows"), (int)PlayerMatch.Element("noOfReds")); allPlayerMatches.AddRange(PlayerMatches.ToList <PlayerMatch>()); }