public IActionResult Index()
        {
            ForumIndexVM viewModel = new ForumIndexVM();

            viewModel.Forums = _forumRep.ListOfForums();

            return(View(viewModel));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            IEnumerable <ForumVM> forums = _forumService.GetAll()
                                           .Select(forum => new ForumVM
            {
                Id          = forum.Id,
                Title       = forum.Title,
                Description = forum.Description,
                PostsCount  = forum.Posts.Count()
            });
            var vm = new ForumIndexVM()
            {
                ForumList = forums
            };

            return(View(vm));
        }
Esempio n. 3
0
        public IActionResult Index()
        {
            var forums = _forumService.GetAll().Select(f => new ForumListingVM
            {
                Id            = f.Id,
                Title         = f.Title,
                Description   = f.Description,
                NumberOfPosts = f.Posts?.Count() ?? 0,
                Latest        = GetLatestPost(f.Id) ?? new PostListingVM(),
                NumberOfUsers = _forumService.GetActiveUsers(f.Id).Count(),
                Image         = f.Image,
                HasRecentPost = _forumService.HasRecentPost(f.Id)
            });

            var forumsListingModels = forums as IList <ForumListingVM> ?? forums.ToList();

            var model = new ForumIndexVM
            {
                ForumsList     = forumsListingModels.OrderBy(forum => forum.Title),
                NumberOfForums = forumsListingModels.Count()
            };

            return(View(model));
        }