@@ -44,10 +44,8 @@ public PollingController(IContentService contentService, IUserValidationService
44
44
_userValidationService = userValidationService ;
45
45
}
46
46
47
- public List < Dictionary < string , string > > GetPublishedContent ( )
47
+ public List < Dictionary < string , string > > GetContent ( )
48
48
{
49
- var publishedContent = new List < Dictionary < string , string > > ( ) ;
50
-
51
49
string username = string . Empty ;
52
50
string password = string . Empty ;
53
51
@@ -72,32 +70,18 @@ public List<Dictionary<string, string>> GetPublishedContent()
72
70
var isAuthorized = _userValidationService . Validate ( username , password , Options . UserGroup ) . GetAwaiter ( ) . GetResult ( ) ;
73
71
if ( ! isAuthorized ) return null ;
74
72
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 ( ) ;
77
75
78
- foreach ( var publishedContentRoot in rootNodes )
76
+ return new List < Dictionary < string , string > >
79
77
{
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 >
89
79
{
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 ( ) }
97
83
}
98
- }
99
-
100
- return publishedContent ;
84
+ } ;
101
85
}
102
86
103
87
}
0 commit comments