Пример #1
0
        /// <summary>
        /// Gets user input into a model for making a new Forum.
        /// </summary>
        /// <param name="model">NewForumModel obj.; what is needed at least to make a new one.</param>
        /// <returns>Object: a new ForumEntity based on the NewForumModel data template.</returns>
        private ForumEntity BuildForum(NewForumModel model)
        {
            var board = _boardEntityService.GetById(model.BoardId);

            return(new ForumEntity
            {
                Title = model.Title,
                Description = model.Description,
                CreatedAt = DateTime.Now,
                //ImageUrl = imgageUri, // Placeholder; not added; seems silly to have a forum or thread have an picture like a user would have a profile image.
                Board = board
            });
        }
Пример #2
0
        // GET : Board
        /// <summary>
        /// Gets a Board by its ID with all of its Forums for listing.
        /// </summary>
        /// <param name="id">Int: board ID.</param>
        /// <returns>Object: a Board's data, its Forum collection, and some of their data.</returns>
        public IActionResult Board(int id)
        {
            var board  = _boardEntityService.GetById(id);
            var forums = board.Forums;

            var forumListings = forums.Select(forum => new ForumListingModel
            {
                Id          = forum.Id,        // int
                Title       = forum.Title,
                Description = forum.Description,
                Board       = BuildBoardListing(forum)
            });

            var model = new BoardForumsModel
            {
                Forums = forumListings,
                Board  = BuildBoardListing(board)
            };

            return(View(model));
        }