Ejemplo n.º 1
0
        public IActionResult Index()
        {
            var forumsOld = _forumService.GetAllOldTestament().Select(forum => new ForumListingModel {
                Id            = forum.Id,
                Title         = forum.Title,
                Description   = forum.Description,
                NumberOfPosts = forum.Posts?.Count() ?? 0, //check to see if its null < ? >
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(forum.Id),
                BookOrder     = forum.BookOrder,
                OldOrNew      = forum.OldOrNew
            });

            var forumsNew = _forumService.GetAllNewTestament().Select(forum => new ForumListingModel
            {
                Id            = forum.Id,
                Title         = forum.Title,
                Description   = forum.Description,
                NumberOfPosts = forum.Posts?.Count() ?? 0, //check to see if its null < ? >
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(forum.Id),
                BookOrder     = forum.BookOrder,
                OldOrNew      = forum.OldOrNew
            });

            var model = new ForumIndexModel {
                ForumListingOld = forumsOld,
                ForumListingNew = forumsNew
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            var forums = _forumService.GetAll().Select(f => new ForumListingModel
            {
                Id            = f.Id,
                Name          = f.Title,
                Description   = f.Description,
                NumberOfPosts = f.Posts?.Count() ?? 0,
                //Latest = GetLatestPost(f.Id) ?? new PostListingModel(),
                NumberOfUsers = _forumService.GetActiveUsers(f.Id).Count(),
                ImageUrl      = f.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(f.Id)
            });

            //var forumListingModels = forums as IList<ForumListingModel> ?? forums.ToList();

            var model = new ForumIndexModel
            {
                ForumList = forums.OrderByDescending(f => f.Id)
                            //ForumList = forumListingModels.OrderBy(forum => forum.Name),
                            //NumberOfForums = forumListingModels.Count()
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        private HomeIndexModel HomeIndexModel()
        {
            var latestPosts  = _post.GetLatestPosts(10);
            var popularPosts = _post.GetMostPopularPosts(10);
            var forumvar     = _forum.GetAll();

            var forums = forumvar.Select(f => new ForumListingModel
            {
                Id            = f.Id,
                Title         = f.Title,
                Description   = f.Description,
                NumberOfPosts = f.Posts?.Count() ?? 0,
                NumberOfUsers = _forum.GetAllActiveUsers(f.Id).Count(),
                ForumImageUrl = f.ImageUrl,
                HasRecentPost = _forum.HasRecentPost(f.Id)
            });

            var posts = latestPosts.Select(p => new PostListingModel {
                Id           = p.Id,
                Title        = p.Title,
                AuthorName   = p.User.UserName,
                AuthorId     = p.User.Id.ToString(),
                AuthorRating = p.User.Rating,
                DatePosted   = p.Created.ToString(),
                RepliesCount = p.Replies.Count(),
                Forum        = GetForumListingForPost(p)
            });
            var postsPopular = popularPosts.Select(p => new PostListingModel {
                Id           = p.Id,
                Title        = p.Title,
                AuthorName   = p.User.UserName,
                AuthorId     = p.User.Id.ToString(),
                AuthorRating = p.User.Rating,
                DatePosted   = p.Created.ToString(),
                RepliesCount = p.Replies.Count(),
                Forum        = GetForumListingForPost(p)
            });

            return(new HomeIndexModel
            {
                LatestPosts = posts,
                PopularPosts = postsPopular,
                SearchQuery = "",
                Forums = forums
            });
        }
        public IActionResult Index()
        {
            var forums = _forumService.GetAll().Select(forum => new ForumListingModel {
                Id            = forum.Id,
                Name          = forum.Title,
                Description   = forum.Description,
                NumberOfPosts = forum.Posts?.Count() ?? 0,
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.UrlImage,
                HasRecentPost = _forumService.HasRecentPost(forum.Id)
            });
            var model = new ForumIndexModel
            {
                ForumList = forums.OrderBy(f => f.Name)
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public IActionResult Index()
        {
            var forums = _forumService.GetAll() //var is IEnumerable<ForumListingModel>
                         .Select(forum => new ForumListingModel {
                Id            = forum.Id,
                Name          = forum.Title,
                Description   = forum.Description,
                NumberOfPosts = forum.Posts?.Count() ?? 0,
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(forum.Id)
            });

            var model = new ForumIndexModel
            {
                ForumList = forums.OrderBy(f => f.Name)
            };

            return(View(model)); //here we can return a view of name of our controller or status code or some JSON data
        }
Ejemplo n.º 6
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,
                Latest        = GetLatestPost(forum.Id) ?? new PostListingModel(),
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(forum.Id)
            });
            var model = new ForumIndexModel
            {
                ForumList = forums
            };

            return(View(model));
        }
Ejemplo n.º 7
0
        public IActionResult Index()
        {
            var forumsList = forumService.GetAll()
                             .Select(forum => new ForumListingViewModel
            {
                Id            = forum.Id,
                Title         = forum.Title,
                Description   = forum.Description,
                NumberOfPosts = forum.Posts?.Count() ?? 0,
                NumberOfUsers = forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageURL,
                HasRecentPost = forumService.HasRecentPost(forum.Id)
            });

            var viewModel = new ForumIndexViewModel()
            {
                ForumList = forumsList.OrderBy(f => f.Title)
            };

            return(View(viewModel));
        }
Ejemplo n.º 8
0
        public IActionResult Index()
        {
            var forums = _forumService.GetAll()
                         .Select(forum => new ForumListingModel {
                Id          = forum.Id,
                Name        = forum.Title,
                Description = forum.Description,
                //if form.Posts is not null, take that as a value(including .Count)
                //if it's null, take 0 as value
                NumberOfPosts = forum.Posts?.Count() ?? 0,
                NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(),
                ImageUrl      = forum.ImageUrl,
                HasRecentPost = _forumService.HasRecentPost(forum.Id)
            });


            var model = new ForumIndexModel
            {
                ForumList = forums.OrderBy(f => f.Name)
            };

            return(View(model));
        }
Ejemplo n.º 9
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));
        }