Beispiel #1
0
        private QueryResult<NewsItem> GetProductNewsInternal(NewsQuery query)
        {
            var path = Path.Combine(_appPaths.CachePath, "news.json");

            var items = GetNewsItems(path).OrderByDescending(i => i.Date);

            var itemsArray = items.ToArray();
            var count = itemsArray.Length;

            if (query.StartIndex.HasValue)
            {
                itemsArray = itemsArray.Skip(query.StartIndex.Value).ToArray();
            }

            if (query.Limit.HasValue)
            {
                itemsArray = itemsArray.Take(query.Limit.Value).ToArray();
            }

            return new QueryResult<NewsItem>
            {
                Items = itemsArray,
                TotalRecordCount = count
            };
        }
Beispiel #2
0
 public QueryResult<NewsItem> GetProductNews(NewsQuery query)
 {
     try
     {
         return GetProductNewsInternal(query);
     }
     catch (FileNotFoundException)
     {
         // No biggie
         return new QueryResult<NewsItem>
         {
             Items = new NewsItem[] { }
         };
     }
 }