@@ -44,10 +44,8 @@ public PollingController(IContentService contentService, IUserValidationService
4444 _userValidationService = userValidationService ;
4545 }
4646
47- public List < Dictionary < string , string > > GetPublishedContent ( )
47+ public List < Dictionary < string , string > > GetContent ( )
4848 {
49- var publishedContent = new List < Dictionary < string , string > > ( ) ;
50-
5149 string username = string . Empty ;
5250 string password = string . Empty ;
5351
@@ -72,32 +70,18 @@ public List<Dictionary<string, string>> GetPublishedContent()
7270 var isAuthorized = _userValidationService . Validate ( username , password , Options . UserGroup ) . GetAwaiter ( ) . GetResult ( ) ;
7371 if ( ! isAuthorized ) return null ;
7472
75- var rootNodes = _contentService . GetRootContent ( ) . Where ( p => p . Published )
76- . OrderByDescending ( p => p . PublishDate ) ;
73+ var root = _contentService . GetRootContent ( ) . Where ( p => p . Published )
74+ . OrderByDescending ( p => p . PublishDate ) . FirstOrDefault ( ) ;
7775
78- foreach ( var publishedContentRoot in rootNodes )
76+ return new List < Dictionary < string , string > >
7977 {
80- publishedContent . Add ( new Dictionary < string , string >
81- {
82- { Constants . Content . Id , publishedContentRoot . Id . ToString ( ) } ,
83- { Constants . Content . Name , publishedContentRoot . Name } ,
84- { Constants . Content . PublishDate , publishedContentRoot . PublishDate . Value . ToString ( ) }
85- } ) ;
86-
87- var ancestors = _contentService . GetAncestors ( publishedContentRoot ) ;
88- foreach ( var ancestor in ancestors )
78+ new Dictionary < string , string >
8979 {
90- publishedContent . Add ( new Dictionary < string , string >
91- {
92- { Constants . Content . Id , ancestor . Id . ToString ( ) } ,
93- { Constants . Content . Name , ancestor . Name } ,
94- { Constants . Content . PublishDate , ancestor . PublishDate . Value . ToString ( ) }
95- } ) ;
96-
80+ { Constants . Content . Id , root ? . Id . ToString ( ) } ,
81+ { Constants . Content . Name , root ? . Name } ,
82+ { Constants . Content . PublishDate , root ? . PublishDate . ToString ( ) }
9783 }
98- }
99-
100- return publishedContent ;
84+ } ;
10185 }
10286
10387 }
0 commit comments