Example #1
0
        /// <summary>
        /// Deletes the anime groups and user mappings as well as resetting group filters and moves all anime series into the specified group.
        /// </summary>
        /// <param name="session">The NHibernate session.</param>
        /// <param name="tempGroupId">The ID of the temporary anime group to use for migration.</param>
        private void ClearGroupsAndDependencies(ISessionWrapper session, int tempGroupId)
        {
            _log.Info("Removing existing AnimeGroups and resetting GroupFilters");

            _animeGroupUserRepo.DeleteAll(session);
            _animeGroupRepo.DeleteAll(session, tempGroupId);
            session.CreateSQLQuery(@"
                UPDATE AnimeSeries SET AnimeGroupID = :tempGroupId;
                UPDATE GroupFilter SET GroupsIdsString = '{}';")
            .SetInt32("tempGroupId", tempGroupId)
            .ExecuteUpdate();

            // We've deleted/modified all AnimeSeries/GroupFilter records, so update caches to reflect that
            _animeSeriesRepo.ClearCache();
            _groupFilterRepo.ClearCache();
            _log.Info("AnimeGroups have been removed and GroupFilters have been reset");
        }