public IActionResult Topics(int id)
        {
            var forum = _forumService.GetById(id);

            if (forum != null)
            {
                var topics = forum.Topics;

                var topicListings = topics.Select(topic => ModelBuilders.BuildTopicListing(topic))
                                    .OrderByDescending(topic => topic.LastPostCreated);

                var model = new ForumTopicModel
                {
                    Forum  = ModelBuilders.BuildForumListing(forum),
                    Topics = topicListings
                };

                if (TempData["TopicDeletedMessage"] != null)
                {
                    model.TopicDeletedMessage = TempData["TopicDeletedMessage"] as string;
                }

                return(View(model));
            }

            return(RedirectToAction("Index", "Forum"));
        }
Beispiel #2
0
        public IActionResult Results(string searchQuery)
        {
            var topics       = _topicService.GetFilteredTopics(searchQuery);
            var areNoResults = (!string.IsNullOrEmpty(searchQuery) && !topics.Any());

            var topicListings = topics.Select(topic => ModelBuilders.BuildTopicListing(topic));

            var model = new SearchResultModel
            {
                Topics             = topicListings,
                SearchQuery        = searchQuery,
                EmptySearchResults = areNoResults
            };

            return(View(model));
        }