Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private List<CarDTO> BuildCarsToDelete(IList<CarDTO> newCars, IList<CarDTO> existingCars)
- {
- var missingCars = new List<CarDTO>();
- var cars = newCars.Select(c => c.CarId);
- var newCarIds = new HashSet<int>(cars);
- foreach (var car in existingCars)
- {
- //If there are no new cars then it had some and they have been removed
- if (newCars.Count() == 0)
- {
- missingCars.Add(car);
- }
- else
- {
- if (!newCarIds.Contains(car.CarId))
- {
- missingCars.Add(car);
- }
- }
- }
- return missingCars;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement