Пример #1
0
        private void PerformDeleteOperation(FootballTeam toDelete)
        {
            FootballTeam team;

            if (!TeamsByID.TryRemove(toDelete.Id, out team))
            {
                throw new Exception("Error: Unable to delete team");
            }

            if (!TeamsNameAndCoach.TryRemove(new Tuple <string, string>(toDelete.TeamName, toDelete.CoachName), out team))
            {
                TeamsByID.TryAdd(toDelete.Id, toDelete);
                throw new Exception("Error: Unable to delete team");
            }
        }
Пример #2
0
        public void CreateTeam(string teamName, string coachName)
        {
            FootballTeam team = new FootballTeam(teamName, coachName);

            team.Id = Guid.NewGuid();

            if (!TeamsByID.TryAdd(team.Id, team))
            {
                throw new Exception("Error: The team was created but it could not be inserted into the Storage");
            }

            if (!TeamsNameAndCoach.TryAdd(new Tuple <string, string>(team.TeamName, team.CoachName), team))
            {
                TeamsByID.TryRemove(team.Id, out team);
                throw new Exception("Error: The team was created but it could not be inserted into the Storage");
            }
        }