コード例 #1
0
        private static void UpdateCityDistricts(RoomForRentAnnouncement roomForRentAnnouncement, ICollection <Guid> cityDistricts)
        {
            var cityDistrictsToRemove = roomForRentAnnouncement.CityDistricts.Except(cityDistricts).ToList();
            var cityDistrictsToAdd    = cityDistricts.Except(roomForRentAnnouncement.CityDistricts).ToList();

            foreach (var cityDistrict in cityDistrictsToRemove)
            {
                roomForRentAnnouncement.RemoveCityDistrict(cityDistrict);
            }

            foreach (var cityDistrict in cityDistrictsToAdd)
            {
                roomForRentAnnouncement.AddCityDistrict(cityDistrict);
            }
        }