public async Task <IActionResult> Get() { Models.ViewModels.IndexViewModel viewModel = new Models.ViewModels.IndexViewModel() { // get topics with most mentions Trending = _context.EntryToTopics .OrderByDescending(pt => pt.EntryId) .Take(20) .Include(pt => pt.Topic) .GroupBy(pt => pt.Topic) .OrderByDescending(group => group.Count()) .Select(group => group.Key) .Take(5) .AsNoTracking() }; var layouts = new List <List <int> >() { new List <int>() { 9, 48, 3, 48, 5, 48, 24, 7, 7, 48 }, new List <int>() { 24, 7, 7, 48, 5, 48, 6, 48, 24, 6, 6, 48 }, new List <int>() { 24, 7, 7, 48, 5, 48 } }; var articles = await _context.Entries .Include(a => a.EntryToTopics) .ThenInclude(at => at.Topic) .AsNoTracking() .ToListAsync(); viewModel.Groupings = GroupArticles(articles.OrderByDescending(a => RankHalfTime(a.Rank, a.Date)), layouts); return(View("Index", viewModel)); }
// список страниц public ActionResult Index(int?id) { #region debug core string conn = ConfigurationManager.AppSettings["conn"]; ContentResult cr = new ContentResult(); cr.Content = conn; //return cr; #endregion PageServices pageServices = new PageServices(); Models.ViewModels.IndexViewModel VM = new Models.ViewModels.IndexViewModel(); VM.selectedCat_ID = id; VM.webRoot = Server.MapPath("~/");// _env.WebRootPath; VM.pageCategories = pageServices.GetPageCategories().ToList(); VM.pages = pageServices.GetPages(id); return(View(VM)); }