public Team Save(Team team) { var teams = this.Retrieve(); var maxID = teams.Max(t => t.ID); team.ID = maxID + 1; teams.Add(team); WriteData(teams); return team; }
public Team Save(int id, Team team) { var teams = this.Retrieve(); var itemIndex = teams.FindIndex(t => t.ID == team.ID); if (itemIndex > 0) { teams[itemIndex] = team; } else { return null; } WriteData(teams); return team; }