示例#1
0
        private static void SyncDeletedBlackout(FakeBlackoutDateRepository dateRepository)
        {
            List <BlackoutDate> orphanedItems = new List <BlackoutDate>();

            foreach (var date in dateRepository.Dates)
            {
                bool exists = false;

                foreach (var schedule in schedules)
                {
                    if (schedule.BlackoutDates.Contains(date))
                    {
                        exists = true;
                    }
                }

                if (!exists)
                {
                    orphanedItems.Add(date);
                }
            }

            foreach (var date in orphanedItems)
            {
                dateRepository.Delete(date);
            }
        }
示例#2
0
        public void Save()
        {
            var itemRepository = new FakeScheduleItemRepository();
            var dateRepository = new FakeBlackoutDateRepository();

            SyncAddedItems(itemRepository);
            SyncDeletedItems(itemRepository);
            SyncAddedBlackout(dateRepository);
            SyncDeletedBlackout(dateRepository);
        }
示例#3
0
 private static void SyncAddedBlackout(FakeBlackoutDateRepository dateRepository)
 {
     foreach (var schedule in schedules)
     {
         foreach (var date in schedule.BlackoutDates)
         {
             if (date.BlackoutDateID == 0 && !dateRepository.Exists(date.BlackoutDateID))
             {
                 dateRepository.AddBlackoutDate(date);
             }
         }
     }
 }