private void SaveAlbums(Image image, List <int> albumsIds) { if (image != null && albumsIds != null) { IEnumerable <int> imageAlbumsIds = albumsImagesRepository.GetAlbumsIdsWithImage(image.Id); IEnumerable <int> addedAlbumsIds = albumsIds.Except(imageAlbumsIds); IEnumerable <int> removedAlbumsIds = imageAlbumsIds.Except(albumsIds); imageRepository.AddToAlbums(image, addedAlbumsIds); imageRepository.RemoveFromAlbums(image, removedAlbumsIds); } }