Exemple #1
0
        protected override void Update(Franchise franchise, IDbConnection connection, IDbTransaction transaction)
        {
            connection.Update(franchise, transaction);

            if (franchise.Entry != null)
            {
                connection.Update(franchise.Entry, transaction);
                this.UpdateMergedDisplayNumbers(franchise);
            }

            var updater = new DependentEntityUpdater(connection, transaction);

            updater.UpdateDependentEntities(
                franchise,
                franchise.Titles,
                title => title.FranchiseId,
                (title, franchiseId) => title.FranchiseId = franchiseId);

            this.InsertEntries(
                franchise.Entries.Where(entry => entry.Id == default), franchise.Id, connection, transaction);

            updater.UpdateDependentEntities(
                franchise,
                franchise.Entries,
                entry => entry.ParentFranchiseId,
                (entry, franchiseId) => entry.ParentFranchiseId = franchiseId);
        }
        protected override void Update(Series series, IDbConnection connection, IDbTransaction transaction)
        {
            series.KindId = series.Kind.Id;

            connection.Update(series, transaction);

            var updater = new DependentEntityUpdater(connection, transaction);

            updater.UpdateDependentEntities(
                series,
                series.Titles,
                title => title.SeriesId,
                (title, seriesId) => title.SeriesId = seriesId);

            updater.UpdateDependentEntities(
                series,
                series.Seasons,
                season => season.SeriesId,
                (season, seriesId) => season.SeriesId = seriesId,
                season => this.InsertSeasonDependentEntities(season, connection, transaction),
                season => this.DeleteSeasonDependentEntities(season, connection, transaction));

            foreach (var season in series.Seasons)
            {
                updater.UpdateDependentEntities(
                    season,
                    season.Periods,
                    period => period.SeasonId,
                    (period, seasonId) => period.SeasonId = seasonId);

                updater.UpdateDependentEntities(
                    season,
                    season.Titles,
                    title => title.SeasonId,
                    (title, seasonId) => title.SeasonId = seasonId);
            }

            updater.UpdateDependentEntities(
                series,
                series.SpecialEpisodes,
                episode => episode.SeriesId,
                (episode, seriesId) => episode.SeriesId = seriesId,
                episode => this.InsertSpecialEpisodeDependentEntities(episode, connection, transaction),
                episode => this.DeleteSpecialEpisodeDependentEntities(episode, connection, transaction));

            if (series.Entry != null)
            {
                connection.Update(series.Entry, transaction);
            }
        }