public void SaveChanges()
 {
     _dbContext.SaveChanges();
 }
Beispiel #2
0
 public void SaveChanges()
 {
     _dbContext.SaveChanges();
     _sequenceRebuilder.Execute(_dbContext, e => e.CustomId);
 }
Beispiel #3
0
 public void SaveChanges()
 {
     _dbContext.SaveChanges();
     _scheduleCache.Clear();
 }
 public void Flush()
 {
     _dbContext.SaveChanges();
 }
        public void Execute(Guid salesAreaId)
        {
            var salesArea = _dbContext.Find <SalesArea>(salesAreaId);

            if (salesArea is null)
            {
                throw new InvalidOperationException($"SalesArea with id {salesAreaId} was not found");
            }

            (Guid[] notStartedRunIds, int[] notStartedPassIds) = GetNotStartedRunPassIds();

            var breaksToDelete = GatherBreaks(salesArea);

            var clashDiffsToDelete = GatherClashDifferences(salesArea);

            (List <Restriction> restrictionsToDelete,
             List <RestrictionSalesArea> restrictionSalesAreasToDelete) = GatherRestrictions(salesArea);

            var inventoryLocksToDelete = GatherInventoryLocks(salesArea);

            var librarySalesAreaPassPrioritiesToDelete = GatherLibrarySalesAreaPassPriorities(salesArea);

            var isrSettingsToDelete = GatherIsrSettings(salesArea);

            var rsSettingsToDelete = GatherRsSettings(salesArea);

            var breakExclusionsToDelete = GatherBreakExclusions(salesArea, notStartedPassIds);

            var passSalesAreaPrioritiesToDelete = GatherPassSalesAreaPriorities(salesArea, notStartedPassIds);

            (List <PassRatingPoint> passRatingPointsToDelete,
             List <PassRatingPoint> passRatingPointsToUpdate) = GatherPassRatingPoints(salesArea, notStartedPassIds);

            var ratingsPredictionSchedulesToDelete = GatherRatingsPredictionSchedules(salesArea);

            var runSalesAreaPrioritiesToDelete = GatherRunSalesAreaPriorities(salesArea, notStartedRunIds);

            var programmesToDelete = GatherProgrammes(salesArea);

            var salesAreaDemographicsToDelete = GatherSalesAreaDemos(salesArea);

            var schedulesToDelete = GatherSchedules(salesArea);

            var universesToDelete = GatherUniverses(salesArea);

            (List <SponsorshipItem> sponsorshipItemsToDelete,
             List <SponsorshipItem> sponsorshipItemsToUpdate) = GatherSponsorshipItems(salesArea);

            (List <SpotBookingRule> spotBookingRulesToDelete,
             List <SpotBookingRuleSalesArea> spotBookingRuleSalesAreasToDelete) = GatherSpotBookingRules(salesArea);

            var spotsToDelete = GatherSpots(salesArea);

            var totalRatingsToDelete = GatherTotalRatings(salesArea);

            var transaction = _dbContext.Specific.Database.BeginTransaction();

            try
            {
                _dbContext.BulkInsertEngine.BulkDelete(breaksToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(clashDiffsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(restrictionsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(restrictionSalesAreasToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(inventoryLocksToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(librarySalesAreaPassPrioritiesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(isrSettingsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(rsSettingsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(breakExclusionsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(passSalesAreaPrioritiesToDelete);
                _dbContext.RemoveRange(passRatingPointsToDelete.ToArray());
                _dbContext.BulkInsertEngine.BulkDelete(ratingsPredictionSchedulesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(runSalesAreaPrioritiesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(programmesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(salesAreaDemographicsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(schedulesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(universesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(sponsorshipItemsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(spotBookingRulesToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(spotBookingRuleSalesAreasToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(spotsToDelete);
                _dbContext.BulkInsertEngine.BulkDelete(totalRatingsToDelete);

                _dbContext.BulkInsertEngine.BulkUpdate(passRatingPointsToUpdate);
                _dbContext.BulkInsertEngine.BulkUpdate(sponsorshipItemsToUpdate);

                _dbContext.Remove(salesArea);

                _dbContext.SaveChanges();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw;
            }
            finally
            {
                transaction.Dispose();
            }
        }
Beispiel #6
0
 public void SaveChanges()
 {
     _dbContext.SaveChanges();
     _cachedAutoBookSettings = null;
 }