public static List <Photo> GetPhotos(this RealEstateItem realEstateItem, MultiplePhotoType photoType) { List <Photo> photos = null; var itemAlbum = App.Prepare().WorkWith().Albums() .Where(album => album.Title.Equals(realEstateItem.ItemNumber, StringComparison.OrdinalIgnoreCase)) .Get().FirstOrDefault(); if (itemAlbum != null) { var allPhotos = itemAlbum.Images() .Where(i => i.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live); Guid tagId = Guid.Empty; if (photoType == MultiplePhotoType.OverviewTabPhoto) { tagId = RealEstateModule.OverviewTabPhotoTaxonId; } else if (photoType == MultiplePhotoType.PhotosTabPhoto) { tagId = RealEstateModule.PhotosTabPhotoTaxonId; } else if (photoType == MultiplePhotoType.PanaromicViewTabPhoto) { tagId = RealEstateModule.PanaromicViewTabPhotoTaxonId; } else if (photoType == MultiplePhotoType.FloorPlanTabPhoto) { tagId = RealEstateModule.FloorPlanTabPhotoTaxonId; } if (!tagId.Equals(Guid.Empty)) { photos = ( from p in allPhotos.Where(p => (p.GetValue <TrackedList <Guid> >("Category")).Contains(tagId)) select new Photo { Id = p.Id, Title = p.Title, Description = p.Description, Url = string.Format("{0}{1}", librariesManager.GetItemUrl(p), p.Extension) } ) .ToList(); } else { // initialize to an empty list of photos photos = new List <Photo>(0); } } return(photos); }