示例#1
0
        public IEnumerable <HackerPost> Get([FromQuery] int page, [FromQuery] string sortby)
        {
            // Get from HackerPostContainer
            HackerPost[] posts = HackerPostContainer.GetHackerNewsPage(page);

            // Sort if
            if (sortby == "score")
            {
                // Return sorted by score
                IComparer byScore = new CompareByScore();
                Array.Sort(posts, byScore);
            }
            else if (sortby == "alpha")
            {
                // Return alphabetical order
                IComparer byAlpha = new CompareByAlpha();
                Array.Sort(posts, byAlpha);
            }
            // else Return natural order

            // Return
            return(posts);
        }
示例#2
0
 public bool GetTriggerRefresh()
 {
     // Trigger a refresh of the HackerPostContainer
     HackerPostContainer.RefreshCache();
     return(true);
 }