public SidebarData GetSidebarData()
        {
            var recipes = RecipesRepo.GetAll();

            var topRecipes = recipes
                             .OrderByDescending(x => x.Views)
                             .Take(Convert.ToInt32(Configuration["SidebarRecipesCount"]))
                             .Select(x => new SidebarRecipe()
            {
                Id          = x.Id,
                Title       = x.Title,
                DateCreated = x.DateCreated.Value,
                Views       = x.Views
            })
                             .ToList();

            var recentRecipes = recipes
                                .OrderByDescending(x => x.DateCreated)
                                .Take(Convert.ToInt32(Configuration["SidebarRecipesCount"]))
                                .Select(x => new SidebarRecipe()
            {
                Id          = x.Id,
                Title       = x.Title,
                DateCreated = x.DateCreated.Value,
                Views       = x.Views
            })
                                .ToList();

            var sidebarData = new SidebarData();

            sidebarData.TopRecipes    = topRecipes;
            sidebarData.RecentRecipes = recentRecipes;

            return(sidebarData);
        }
Esempio n. 2
0
        //Add Top and Recent Blogs To SidebarData
        private SidebarData AddToSidebarData(List <SidebarBlog> topBlogs, List <SidebarBlog> recentBlogs)
        {
            SidebarData sidebarData = new SidebarData();

            sidebarData.RecentBlogs = recentBlogs;
            sidebarData.TopBlogs    = topBlogs;
            return(sidebarData);
        }
Esempio n. 3
0
        public SidebarData GetSidebarData()
        {
            List <Blog> blogs = BlogRepository.GetAll();

            List <SidebarBlog> topBlogs = GetTopBlogs(blogs);

            List <SidebarBlog> recentBlogs = GetRecentBlogs(blogs);

            SidebarData sidebarData = AddToSidebarData(topBlogs, recentBlogs);

            return(sidebarData);
        }