Ejemplo n.º 1
0
        public ActionResult Index(long?selectedFeedId, long?selectedFeedItemId)
        {
            Feed selectedFeed;
            IEnumerable <FeedItem> filteredFeedItems;
            FeedItem selectedFeedItem;

            if (selectedFeedId == null)
            {
                selectedFeed      = null;
                filteredFeedItems = feedService.GetAllFeedItems(
                    Ord <FeedItem>(fi => fi.PublishedOn, ListSortDirection.Descending));
            }
            else
            {
                selectedFeed = feedService.FindFeedById((long)selectedFeedId);

                if (selectedFeed == null)
                {
                    return(HttpNotFound());
                }

                filteredFeedItems = feedService.GetFeedItemsInFeed(
                    selectedFeed, Ord <FeedItem>(fi => fi.PublishedOn, ListSortDirection.Descending));
            }

            if (selectedFeedItemId == null)
            {
                selectedFeedItem = filteredFeedItems.FirstOrDefault();
            }
            else
            {
                selectedFeedItem = feedService.FindFeedItemById((long)selectedFeedItemId);

                if (selectedFeedItem == null)
                {
                    return(HttpNotFound());
                }
            }

            MainFeedDisplayViewModel vm = new MainFeedDisplayViewModel(
                feedService.GetAllFeeds(),
                filteredFeedItems,
                selectedFeed,
                selectedFeedItem
                );

            return(View(vm));
        }
 // GET: FeedItems
 public ActionResult Index()
 {
     return(View(feedService.GetAllFeedItems()));
 }