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); } }
public void Save() { var itemRepository = new FakeScheduleItemRepository(); var dateRepository = new FakeBlackoutDateRepository(); SyncAddedItems(itemRepository); SyncDeletedItems(itemRepository); SyncAddedBlackout(dateRepository); SyncDeletedBlackout(dateRepository); }
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); } } } }