Beispiel #1
0
        public ActionResult ArticleList(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, int?page)
        {
            ArticleListModel model = new ArticleListModel();

            PageModel.Title       = "";
            PageModel.Description = "";
            PageModel.Author      = "";
            PageModel.Keywords    = "";

            string url = HttpContext.Request.RawUrl;
            //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", "");

            Category cat = StaticConfig.GetCatigory(categoryUrl, subCategoryUrl, subSubCategoryUrl);

            model.CrumbLinkList   = StaticConfig.GenerateCrumbLinks(cat, articleType);
            model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType);
            model.PageLinkBase    = StaticConfig.BaseSiteUrl + articleType;
            if (categoryUrl != "")
            {
                model.PageLinkBase += "/" + cat.CategoryUrl;
            }
            if (subCategoryUrl != "")
            {
                model.PageLinkBase += "/" + cat.SecondLevCategoryUrl;
            }
            if (subSubCategoryUrl != "")
            {
                model.PageLinkBase += "/" + cat.ThirdLevCategoryUrl;
            }
            //model.PageLinkBase = model.CrumbLinkList.Last().Href;
            //model.RelatedTreeView = StaticConfig.TreeView(cat, model.PageLinkBase);

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                //BASED ON CAT
                //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.Category.CategoryId == cat.CategoryId).OrderBy(a => a.CreatedDate);
                if (categoryUrl != "")
                {
                    model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.Category.CategoryId == cat.CategoryId && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
                    //model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
                    if (subSubCategoryUrl != "")
                    {
                        model.Into = db.Articles.Where(a => a.URLLink == subSubCategoryUrl).FirstOrDefault();
                    }
                    else if (subCategoryUrl != "")
                    {
                        model.Into = db.Articles.Where(a => a.URLLink == subCategoryUrl).FirstOrDefault();
                    }
                    else
                    {
                        model.Into = db.Articles.Where(a => a.URLLink == categoryUrl).FirstOrDefault();
                    }
                }
                else
                {
                    model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == articleType && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
                }

                model.Into       = new Article();
                model.Into.Title = "Text of H1 in work";
                //CHECK PAGING
                //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1);
                //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
            }
            //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize);
            return(View(model));
        }