Esempio n. 1
0
        public CategorySingleViewModel LoadBlogsByCategory(String category)
        {
            var catModel = new CategorySingleViewModel();

            category = ContentUtils.GetFormattedUrl(category);


            catModel.AllBlogsInCategory = _context.Blogs.Where(x => x.Category.CategoryNameFormatted == category && x.IsActive)
                        .OrderByDescending(blog => blog.Date)
                        .ToList();

            catModel.BlogRoll = catModel.AllBlogsInCategory
                .Take(catModel.MaxBlogCount)
                .ToList();


            catModel.TheCategory = _context.BlogCategories.FirstOrDefault(x => x.CategoryNameFormatted == category);
            var model = new BlogListModel(_context);
            catModel.MaxBlogCount = model.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad;
            catModel.SkipBlogs = catModel.MaxBlogCount;
            catModel.BlogTitle = model.GetBlogSettings().BlogTitle;

            catModel.BlogsByCat = catModel.AllBlogsInCategory
                        .Take(catModel.MaxBlogCount)
                        .ToList();

            return catModel;
        }
        public ActionResult Categories(string category)
        {
            // Blog Listing Homepage
            if (String.IsNullOrEmpty(category))
            {
                var model = new CategoryHomeViewModel();

                return View("~/Views/Blog/CategoriesHome.cshtml", model);
            }
            // Individual Blog
            else
            {
                var model = new CategorySingleViewModel(category, Server);

                return View("~/Views/Blog/CategoriesSingle.cshtml", model);
            }
        }