Guest User

Guest User

  • Tech Writer
  • 4
  • 434

Get Page URL Path

May 5 2021 8:05 AM
Hello everyone i have use this code for get blog post detail
  1. private async Task<PagedQueryResult<BlogPostSummary>> MapBlogPostsAsync(PagedQueryResult<CustomEntityRenderSummary> customEntityResult)  
  2. {  
  3. var blogPosts = new List<BlogPostSummary>(customEntityResult.Items.Count());  
  4. var imageAssetIds = customEntityResult  
  5. .Items  
  6. .Select(i => (BlogPostDataModel)i.Model)  
  7. .Select(m => m.ThumbnailImageAssetId)  
  8. .Distinct();  
  9. var images = await _imageAssetRepository.GetImageAssetRenderDetailsByIdRangeAsync(imageAssetIds);  
  10. foreach (var customEntity in customEntityResult.Items)  
  11. {  
  12. var model = (BlogPostDataModel)customEntity.Model;  
  13. var blogPost = new BlogPostSummary();  
  14. blogPost.Title = customEntity.Title;  
  15. blogPost.ShortDescription = model.ShortDescription;  
  16. blogPost.ThumbnailImageAsset = images.GetOrDefault(model.ThumbnailImageAssetId);  
  17. blogPost.FullPath = customEntity.PageUrls.FirstOrDefault(); --Here get full path of page . it's working fine  
But I have use this code for categorypage full path here null value display.
  1. private ICollection<CategorySummary> MapCategories(PagedQueryResult<CustomEntityRenderSummary> customEntityResult)  
  2. {  
  3. var categories = new List<CategorySummary>(customEntityResult.Items.Count());  
  4. foreach (var customEntity in customEntityResult.Items)  
  5. {  
  6. var model = (CategoryDataModel)customEntity.Model;  
  7. var category = new CategorySummary();  
  8. category.CategoryId = customEntity.CustomEntityId;  
  9. category.Title = customEntity.Title;  
  10. category.ShortDescription = model.ShortDescription;  
  11. category.UrlSlug = customEntity.UrlSlug;  
  12. category.FullPath = customEntity.PageUrls.FirstOrDefault(); 
Please check this .

Answers (3)