Beispiel #1
0
        public IActionResult Index()
        {
            IEnumerable <ForumListingModel> forums = _forumService.GetAll().Select(forum => new ForumListingModel
            {
                Id             = forum.Id,
                Name           = forum.Title,
                Description    = forum.Description,
                NumberOfPosts  = forum.Posts?.Count() ?? 0,
                NumberOfUsers  = _forumService.GetAllActiveUsers(forum.Id).Count(),
                ImageUrl       = forum.ImageUrl,
                HasRecentPosts = _forumService.HasRecentPosts(forum.Id)
            });
            var model = new ForumIndexModel
            {
                ForumList = forums.OrderBy(f => f.Name)
            };

            return(View(model));
        }