예제 #1
0
        /// <summary>
        /// Add a season (to the end) to the list with correct season number
        /// update number of seasons
        ///
        /// error if the season number doesn't match the id in the Dicionnary
        /// </summary>
        /// <param name="season"></param>
        /// <exception cref="Exception">Season number and key doesn't match</exception>
        /// <returns>Updated Dictionary of Seasons</returns>
        public Dictionary <int, Season> AddSeason(Season season)
        {
            checkSeasonNumberIndex(season.SeasonNumber, NumberSeasons + 1);

            ListSeasons.Add(season.SeasonNumber, season);
            NumberSeasons += 1;
            return(ListSeasons);
        }
예제 #2
0
        /// <summary>
        /// Edit a season by passing the index of the season
        ///
        /// return an error if the season doesn't exist
        /// error if the season number doesn't match the id in the Dicionnary
        /// </summary>
        /// <param name="index"></param>
        /// <param name="season"></param>
        /// <exception cref="Exception">Season number and key doesn't match</exception>
        /// <exception cref="Exception">The season doesn't exist</exception>
        /// <returns>Updated Dictionary of Seasons</returns>
        public Dictionary <int, Season> EditSeason(int index, Season season)
        {
            checkSeasonNumberIndex(season.SeasonNumber, index);

            if (!ListSeasons.ContainsKey(index))
            {
                throw new SerieException(SerieEnum.NOTEXIST);
            }
            ListSeasons[index] = season;
            return(ListSeasons);
        }
예제 #3
0
        /// <summary>
        /// Surcharge AddSeason allowing to add a season with the episode number wanted
        ///
        /// return an error if the key already exist
        /// error if the season number doesn't match the id in the Dicionnary
        /// </summary>
        /// <param name="index"></param>
        /// <param name="season"></param>
        /// <exception cref="Exception">Season number and key doesn't match</exception>
        /// <exception cref="Exception">The season already exist</exception>
        /// <returns>Updated Dictionary of Seasons</returns>
        public Dictionary <int, Season> AddSeason(int index, Season season)
        {
            checkSeasonNumberIndex(season.SeasonNumber, index);

            if (ListSeasons.ContainsKey(index))
            {
                throw new SerieException(SerieEnum.EXIST);
            }
            ListSeasons.Add(index, season);
            NumberSeasons += 1;
            return(ListSeasons);
        }