コード例 #1
0
        public async Task <ViewResult> Boards(PagingParams pagingParams)
        {
            var boardModels = await Mediator.Send(new GetBoardsWithPaginationQuery(pagingParams));

            var viewModel = new HomeBoardsViewModel {
                BoardPage = new FrontendPage <GetBoardModel>(boardModels)
            };

            return(View(viewModel));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: jalqueza/F0rum
        public IActionResult Index()
        {
            var model = new HomeBoardsViewModel();

            model.Boards = new List <HomeBoardViewModel>();

            foreach (var board in _boardRepository.GetAllBoards())
            {
                var boardViewModel = new HomeBoardViewModel();
                boardViewModel.Board        = board;
                boardViewModel.threadsCount = board.Threads.Count();
                boardViewModel.postsCount   = 0;
                foreach (var thread in board.Threads)
                {
                    boardViewModel.postsCount = boardViewModel.postsCount + thread.Posts.Count();
                }
                boardViewModel.lastPost = (board.Threads.LastOrDefault() != null) ? board.Threads.OrderBy(t => t.DateTime).LastOrDefault().Posts.OrderBy(p => p.DateTime).LastOrDefault() : null;
                model.Boards.Add(boardViewModel);
            }
            return(View(model));
        }