private async Task<IViewComponentResult> CategoriesAsync(int count) { var categories = await Db.Categories .Select(c => new KeyValuePair<string, string>(c.Name, $"/Category/{c.Id}/{c.Slug}")) .Take(count).ToListAsync(); var sidePanelObj = new SidePanelViewModel { SidePanel = SidePanel.Categories, Heading = "Categories", Data = categories }; return View(sidePanelObj); }
private async Task<IViewComponentResult> TagsAsync(int count) { var tags = await Db.Tags .Select(t => new KeyValuePair<string,string>(t.Name, $"/Tag/{t.Id}/{t.Name.ToSlug()}")) .Take(count).ToListAsync(); var sidePanelObj = new SidePanelViewModel { SidePanel = SidePanel.Tags, Heading = "Tags", Data = tags }; return View(sidePanelObj); }
private async Task<IViewComponentResult> PostRecentAsync(int count) { var posts = await Db.Posts.OrderByDescending(p => p.PostedOn) .Select(p=> new KeyValuePair<string, string>(p.Title, $"/Post/{p.Id}/{p.Slug}")) .Take(count).ToListAsync(); var sidePanelObj = new SidePanelViewModel{ SidePanel = SidePanel.PostRecent, Heading = "Recent Posts", Data = posts }; return View(sidePanelObj); }