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)); }
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)); }
public IActionResult Index() { IEnumerable <ForumListingModel> forums = _forumService .GetAll().Select(forum => new ForumListingModel { Id = forum.Id, Name = forum.Title, Description = forum.Descripition, ImageUrl = forum.ImageUrl, NumberOfPosts = forum.Posts?.Count() ?? 0, NumberOfUsers = _forumService.GetActiveUsers(forum.Id).Count(), HasRecentPost = _forumService.HasRecentPost(forum.Id) }); var model = new ForumIndexModel { ForumList = forums.OrderBy(f => f.Name) }; return(View(model)); }
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)); }
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 }
public IActionResult Index() { var forums = _forumService.GetAll() .Select(forum => new ForumListingModel { Id = forum.Id, Nama = forum.Judul, Deskripsi = forum.Deskripsi, nomorPost = forum.Posts?.Count() ?? 0, nomorUser = _forumService.GetActiveUsers(forum.Id).Count(), ImageUrl = forum.ImageUrl, postBaru = _forumService.postBaru(forum.Id) }); var model = new ForumIndexModel { ForumList = forums.OrderBy(f => f.Nama) }; return(View(model)); }
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)); }
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)); }