예제 #1
0
        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;
        }
예제 #2
0
        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;
        }