Ejemplo n.º 1
0
        public IActionResult Index(int boardId)
        {
            BoardIndexViewModel model = new BoardIndexViewModel();

            model.Board            = _boardRepository.GetById(boardId);
            model.ThreadViewModels = new List <BoardIndexThreadViewModel>();


            foreach (var thread in model.Board.Threads)
            {
                BoardIndexThreadViewModel boardIndexThreadViewModel = new BoardIndexThreadViewModel();
                boardIndexThreadViewModel.Thread       = thread;
                boardIndexThreadViewModel.RepliesCount = thread.Posts.Count();
                boardIndexThreadViewModel.lastPost     = thread.Posts.OrderBy(p => p.DateTime).LastOrDefault();
                model.ThreadViewModels.Add(boardIndexThreadViewModel);
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            SetBreadCrumb("Board Index");

            IEnumerable <Forum> forums = _forumServices.GetViewableForums(_currentUser.UserID);

            IEnumerable <ForumRow> forumRows = forums.Select(x => new ForumRow
            {
                Forum      = x,
                HasNewPost = _forumServices.HasNewPost(x.ForumID, _currentUser.UserID),
                LastPost   = _forumServices.GetLastPost(x.ForumID)
            });

            IEnumerable <Category> categories = forums.Select(x => x.Category).Distinct().OrderBy(item => item.Order);

            var model = new BoardIndexViewModel()
            {
                Categories = categories,
                Forums     = forumRows
            };

            return(View(model));
        }