Ejemplo n.º 1
0
        public ActionResult NewsDetails(string html)
        {
            int categoryRowId = 0;
            Category cat = new Category();
            ArticleModel model = new ArticleModel();
            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == html + ".html").FirstOrDefault();
            }

            if (model.Article == null)
            {
                cat = DIYFEHelper.GetCatigroy(model.Article.CategoryRowId);
                model.Article = new DIYFE.EF.Article();
                model.Comments = new List<DIYFE.EF.ArticleComment>();
                //model.Article.ArticleComments = new List<ArticleComment>();
            }
            else
            {
                DIYFELib.Tracking.InsertArticleViewRequest(model.Article.ArticleId);
            }

            // model.Comments = la.ArticleComments(model.Article.ArticleId);

            //model.MostViewed = la.MostViewed(11, 20);
            // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix);
             model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(cat, linkPrefix);

            ////PageModel.Title = model.Article.Title;
            ////PageModel.Description = model.Article.Description;
            ////PageModel.Author = model.Article.Author;
            ////PageModel.Keywords = model.Article.Keywords;

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult ArticleDetails(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, string articleName)
        {
            int categoryRowId = 0;

            ArticleModel model = new ArticleModel();
            Category cat = new Category();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == articleName + ".html").FirstOrDefault();
                model.Article.ViewRequests++;
                db.Entry(model.Article).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            if (model.Article != null)
            {
                cat = StaticConfig.GetCatigroy(model.Article.CategoryRowId);

                model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(cat, articleType);
                model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType);

                PageModel.Title = model.Article.Title;
                PageModel.Description = model.Article.Description;
                PageModel.Author = model.Article.Author;
                PageModel.Keywords = model.Article.Keywords;
            }
            else
            {
                //JUST TO GET BY -- REPLACE WITH 404 SOULATION
                model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(new Category(), articleType);
                model.Article = new Article();
                model.Comments = new List<ArticleComment>();
                //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix);

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

            // model.Comments = la.ArticleComments(model.Article.ArticleId);

            //model.MostViewed = la.MostViewed(11, 20);
            // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix);
            model.RelatedTreeView = StaticConfig.GenerateTreeViewThirdLev(cat, articleType);

            ////PageModel.Title = model.Article.Title;
            ////PageModel.Description = model.Article.Description;
            ////PageModel.Author = model.Article.Author;
            ////PageModel.Keywords = model.Article.Keywords;

            return View(model);
        }
Ejemplo n.º 3
0
        public static List <CustomHtmlLink> GenerateCrumbLinks(DIYFE.EF.Category cat, string linkPrefix)
        {
            List <CustomHtmlLink> linkList = new List <CustomHtmlLink>();
            //Category cat = AppStatic.Categories
            //                    .Where(c => c.CategoryRowId == categoryRowId)
            //                    .FirstOrDefault();
            CustomHtmlLink rootLink = new CustomHtmlLink();

            rootLink.LinkText = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(linkPrefix) + "s";
            rootLink.Href     = StaticConfig.BaseSiteUrl + linkPrefix + "/";
            rootLink.Title    = linkPrefix;
            linkList.Add(rootLink);

            if (cat != null)
            {
                if (!String.IsNullOrEmpty(cat.CategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.CategoryName;
                    link.Href     = StaticConfig.BaseSiteUrl + linkPrefix + "/" + cat.CategoryUrl;
                    link.Title    = cat.CategoryName;
                    linkList.Add(link);
                }
                if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.SecondLevCategoryName;
                    link.Href     = "/" + linkPrefix + "/" + cat.CategoryUrl + "/" + cat.SecondLevCategoryUrl;
                    link.Title    = cat.SecondLevCategoryName;
                    linkList.Add(link);
                }
                if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.ThirdLevCategoryName;
                    link.Href     = "/" + linkPrefix + "/" + cat.CategoryUrl + "/" + cat.SecondLevCategoryUrl + "/" + cat.ThirdLevCategoryUrl;
                    link.Title    = cat.ThirdLevCategoryName;
                    linkList.Add(link);
                }
            }

            //CustomHtmlLink link2 = new CustomHtmlLink();
            //link2.LinkText = "Bread Crumb Links";
            //link2.Href = "/" + linkPrefix;
            //linkList.Add(link2);

            return(linkList);
        }
Ejemplo n.º 4
0
        //public static List<CustomHtmlLink> GenerateCrumbLinks(string Url)
        //{
        //    List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();

        //    return linkList;
        //}

        public static List <CustomHtmlLink> GenerateCrumbLinks(DIYFE.EF.Category cat, string linkPrefix)
        {
            List <CustomHtmlLink> linkList = new List <CustomHtmlLink>();
            //Category cat = AppStatic.Categories
            //                    .Where(c => c.CategoryRowId == categoryRowId)
            //                    .FirstOrDefault();
            CustomHtmlLink rootLink = new CustomHtmlLink();

            rootLink.LinkText = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(linkPrefix) + "s";
            rootLink.Href     = AppStatic.BaseSiteUrl + linkPrefix + "/";
            rootLink.Title    = "Base diyfe categor";
            linkList.Add(rootLink);

            if (cat != null)
            {
                if (!String.IsNullOrEmpty(cat.CategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.CategoryName;
                    link.Href     = AppStatic.BaseSiteUrl + linkPrefix + "/" + cat.CategoryUrl;
                    link.Title    = cat.CategoryName;
                    linkList.Add(link);
                }
                if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.SecondLevCategoryName;
                    link.Href     = "/" + linkPrefix + "/" + cat.CategoryUrl + "/" + cat.SecondLevCategoryUrl;
                    link.Title    = cat.SecondLevCategoryName;
                    linkList.Add(link);
                }
                if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl))
                {
                    CustomHtmlLink link = new CustomHtmlLink();
                    link.LinkText = cat.ThirdLevCategoryName;
                    link.Href     = "/" + linkPrefix + "/" + cat.CategoryUrl + "/" + cat.SecondLevCategoryUrl + "/" + cat.ThirdLevCategoryUrl;
                    link.Title    = cat.ThirdLevCategoryName;
                    linkList.Add(link);
                }
            }
            else
            {
                throw (new Exception("Generate Crumb Links - - -  Unable to find correct category."));
            }

            return(linkList);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// TODO: REVIEW THIS CRAP, COULD TOTALY DO BETTER
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="linkPrefix"></param>
        /// <returns></returns>
        public static List<CustomHtmlLink> GenerateRelatedTreeView(Category cat, string linkPrefix)
        {
            List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();
            //ListAccess la = new ListAccess();
            //Category cat = AppStatic.Categories
            //                    .Where(c => c.CategoryRowId == categoryRowId)
            //                    .FirstOrDefault();
            linkList.Add(new CustomHtmlLink
               {
                    LinkText = cat.CategoryName,
                    Href = AppStatic.BaseSiteUrl + linkPrefix + "/" + cat.CategoryUrl,
                    Title = cat.CategoryName,
                    SubLinks = GenerateTreeViewSecondLev(cat, linkPrefix)
                });

            linkList[0].SubLinks.AddRange(RelatedArticleLinks(cat,linkPrefix,1));

            return linkList;
        }
Ejemplo n.º 6
0
        public ActionResult AddCategory(DIYFE.EF.Category category)
        {
            var data = new object();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                if (category.ThirdLevCategoryId == 0 && category.SecondLevCategoryId != 0)
                {
                    category.ThirdLevCategoryId = db.Categories.Max(c => c.ThirdLevCategoryId).Value;
                }
                if (category.SecondLevCategoryId == 0)
                {
                    category.SecondLevCategoryId = db.Categories.Max(c => c.SecondLevCategoryId).Value;
                }
                if (category.CategoryId == 0)
                {
                    category.CategoryId = db.Categories.Max(c => c.CategoryId);
                }
                db.Categories.Add(category);
                db.SaveChanges();
                data = new { success = true };
                //allCats = db.Categories.ToList();
            }

            AppStatic.LoadStaticCache();

            //Category cat = new Category();
            //if (cat.InsertCategory(category))
            //{
            //    AppStatic.LoadStaticCache();
            //    data = new { success = true };
            //}
            //else
            //{
            //    data = new { success = false, message = "Failed to insert new category." };
            //    return Json(data);
            //}

            return(Json(data));
        }
Ejemplo n.º 7
0
        public static List<CustomHtmlLink> GenerateTreeViewSecondLev(Category cat, string linkPrefix)
        {
            List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();

            List<Category> secondLevCats = AppStatic.Categories
                                                .Where(c => c.CategoryId == cat.CategoryId
                                                && c.SecondLevCategoryId > 0
                                                && c.ThirdLevCategoryId == 0)
                                                .ToList();

            foreach (Category _secondLevCat in secondLevCats)
            {
                CustomHtmlLink newCat = new CustomHtmlLink
                        {
                            LinkText = _secondLevCat.SecondLevCategoryName,
                            Href = AppStatic.BaseSiteUrl + linkPrefix + "/" + _secondLevCat.CategoryUrl + "/" + _secondLevCat.SecondLevCategoryUrl,
                            Title = _secondLevCat.SecondLevCategoryName,
                            SubLinks = GenerateTreeViewThirdLev(_secondLevCat, linkPrefix)
                        };
                newCat.SubLinks.AddRange(RelatedArticleLinks(_secondLevCat, AppStatic.BaseSiteUrl + linkPrefix, 2));

                linkList.Add(newCat);

            }

            return linkList;
        }
Ejemplo n.º 8
0
        public static List<CustomHtmlLink> RelatedArticleLinks(Category cat, string linkPrefix, int categoryLevel)
        {
            List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();
            List<Article> articles = new List<Article>();
            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                switch (categoryLevel)
                {
                    case 1:
                        articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId
                            && a.Category.SecondLevCategoryId == 0
                            && a.Category.ThirdLevCategoryId == 0
                            ).ToList();
                        // whereSql = "WHERE CategoryId = " + cat.CategoryId;
                        break;
                    case 2:
                        articles = db.Articles.Where(a => a.Category.SecondLevCategoryId == cat.SecondLevCategoryId
                            && a.Category.ThirdLevCategoryId == 0
                            ).ToList();
                        //whereSql = "WHERE SecondLevCategoryId = " + cat.SecondLevCategoryId + " AND CategoryId= " + cat.CategoryId + " AND ThirdLevCategoryId = 0";
                        break;
                    case 3:
                        articles = db.Articles.Where(a => a.Category.ThirdLevCategoryId == cat.ThirdLevCategoryId).ToList();
                        // whereSql = "WHERE ThirdLevCategoryId = " + cat.ThirdLevCategoryId;
                        break;
                    case 4:
                        articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId).ToList();
                        //whereSql = "WHERE CategoryId = " + cat.CategoryId;
                        break;
                    default:
                        break;
                }
            }

            foreach (Article a in articles)
            {

                string articleType = "";
                switch (a.ArticleTypeId)
                {
                    case 1:
                        articleType = "post/";
                        break;
                    case 2:
                        articleType = "project/";
                        break;
                    case 3:
                        articleType = "blog/";
                        break;
                    case 4:
                        articleType = "news/";
                        break;
                    default:
                        articleType = "home/";
                        break;
                }

                string ahref = AppStatic.BaseSiteUrl + articleType + cat.CategoryUrl + "/";
                //MvcHtmlString ahref = new MvcHtmlString("<a href=\"" + AppStatic.BaseSiteUrl + article.Category.CategoryUrl + "/");
                if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl))
                {
                    ahref += cat.SecondLevCategoryUrl + "/";
                }
                if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl))
                {
                    ahref += cat.ThirdLevCategoryUrl + "/";
                }
                ahref += a.URLLink;

                CustomHtmlLink htmlLink = new CustomHtmlLink
                {
                    LinkText = a.Name,
                    Href = ahref,
                    Title = a.Title
                };
                linkList.Add(htmlLink);
            }

            return linkList;
        }
Ejemplo n.º 9
0
 public static Category GetCatigroy(int categoryRowId)
 {
     Category cat = new Category();
         cat = AppStatic.Categories
                         .Where(c => c.CategoryRowId == categoryRowId)
                         .FirstOrDefault();
         return cat;
 }
Ejemplo n.º 10
0
        //public static Category GetCategory(string catOne, string catTwo, string catThree)
        //{
        //    Category category;
        //    int categoryRowId = GetCatigoryRowId(catOne, catTwo, catThree);
        //    category = AppStatic.Categories.Where(c => c.CategoryRowId == categoryRowId).FirstOrDefault();
        //    return category;
        //    #region Old Code
        //    //if (catOne.Length > 0 && catTwo.Length > 0 && catThree.Length > 0)
        //    //{
        //    //    category = AppStatic.Categories
        //    //                    .Where(c => c.CategoryUrl == catOne
        //    //                            && c.SecondLevCategoryUrl == catTwo
        //    //                            && c.ThirdLevCategoryUrl == catThree)
        //    //                    .FirstOrDefault();
        //    //}
        //    //else if (catOne.Length > 0 && catTwo.Length > 0)
        //    //{
        //    //    category = AppStatic.Categories
        //    //                    .Where(c => c.CategoryUrl == catOne
        //    //                            && c.SecondLevCategoryUrl == catTwo
        //    //                            && String.IsNullOrEmpty(c.ThirdLevCategoryUrl))
        //    //                    .FirstOrDefault();
        //    //}
        //    //else
        //    //{
        //    //    category = AppStatic.Categories
        //    //                    .Where(c => c.CategoryUrl == catOne
        //    //                            && String.IsNullOrEmpty(c.SecondLevCategoryUrl))
        //    //                    .FirstOrDefault();
        //    //}
        //    #endregion
        //}
        //public static int GetCatigoryRowId(string url)
        //{
        //    int categoryId = 0;
        //    if (url.StartsWith("/post") && url != "/post")
        //    {
        //        url = url.Substring(5, (url.Length - 1));
        //    }
        //    if (url.StartsWith("/"))
        //    {
        //        url = url.Substring(1, (url.Length-1));
        //    }
        //    string[] catigoryNames = url.Split('/');
        //    switch (catigoryNames.Count())
        //    {
        //        case 1:
        //            categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catigoryNames[0]
        //                                && String.IsNullOrEmpty(c.SecondLevCategoryUrl))
        //                        .Select(c => c.CategoryId)
        //                        .FirstOrDefault();
        //            break;
        //        case 2:
        //            categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catigoryNames[0]
        //                                && c.SecondLevCategoryUrl == catigoryNames[1]
        //                                && String.IsNullOrEmpty(c.ThirdLevCategoryUrl))
        //                        .Select(c => c.CategoryId)
        //                        .FirstOrDefault();
        //            break;
        //        case 3:
        //            categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catigoryNames[0]
        //                                && c.SecondLevCategoryUrl == catigoryNames[1]
        //                                && c.ThirdLevCategoryUrl == catigoryNames[2])
        //                        .Select(c => c.CategoryId)
        //                        .FirstOrDefault();
        //            break;
        //        case 4:
        //            //categoryId = AppStatic.Categories
        //            //            .Where(c => c.CategoryName == catigoryNames[0]
        //            //                && c.SecondLevCategoryName == catigoryNames[1]
        //            //                && c.ThirdLevCategoryName == catigoryNames[2]
        //            //            .Select(c => c.CategoryId)
        //            //            .FirstOrDefault();
        //            break;
        //        default:
        //            break;
        //    }
        //    return categoryId;
        //}
        //public static int GetCatigoryRowId(string catOne, string catTwo, string catThree)
        //{
        //    int categoryId = 0;
        //    if (catOne.Length > 0 && catTwo.Length > 0 && catThree.Length > 0)
        //    {
        //        categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catOne
        //                                && c.SecondLevCategoryUrl == catTwo
        //                                && c.ThirdLevCategoryUrl == catThree)
        //                        .Select(c => c.CategoryRowId)
        //                        .FirstOrDefault();
        //    }
        //    else if (catOne.Length > 0 && catTwo.Length >0 )
        //    {
        //        categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catOne
        //                                && c.SecondLevCategoryUrl == catTwo
        //                                && String.IsNullOrEmpty(c.ThirdLevCategoryUrl))
        //                        .Select(c => c.CategoryRowId)
        //                        .FirstOrDefault();
        //    }
        //    else
        //    {
        //        categoryId = AppStatic.Categories
        //                        .Where(c => c.CategoryUrl == catOne
        //                                && String.IsNullOrEmpty(c.SecondLevCategoryUrl))
        //                        .Select(c => c.CategoryRowId)
        //                        .FirstOrDefault();
        //    }
        //    return categoryId;
        //}
        public static Category GetCatigory(string catOne, string catTwo, string catThree)
        {
            Category cat = new Category();
            catOne = catOne.ToLower();
            catTwo = catTwo.ToLower();
            catThree = catThree.ToLower();
            if (catOne.Length > 0 && catTwo.Length > 0 && catThree.Length > 0)
            {
                cat = AppStatic.Categories
                                .Where(c => c.CategoryUrl == catOne
                                        && c.SecondLevCategoryUrl == catTwo
                                        && c.ThirdLevCategoryUrl == catThree)
                                .FirstOrDefault();
            }
            else if (catOne.Length > 0 && catTwo.Length > 0)
            {
                cat = AppStatic.Categories
                                .Where(c => c.CategoryUrl == catOne
                                        && c.SecondLevCategoryUrl == catTwo
                                        && String.IsNullOrEmpty(c.ThirdLevCategoryUrl))
                                .FirstOrDefault();
            }
            else
            {
                cat = AppStatic.Categories
                                .Where(c => c.CategoryUrl == catOne
                                        && String.IsNullOrEmpty(c.SecondLevCategoryUrl))
                                .FirstOrDefault();
            }

            return cat;
        }
Ejemplo n.º 11
0
        //public static List<CustomHtmlLink> GenerateTreeViewFirstLev(int categoryRowId, string linkPrefix)
        //{
        //    List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();
        //    ListAccess la = new ListAccess();
        //    Category cat = AppStatic.Categories
        //                        .Where(c => c.CategoryRowId == categoryRowId)
        //                        .FirstOrDefault();
        //    if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl))
        //    {
        //        CustomHtmlLink htmlLink = new CustomHtmlLink
        //        {
        //            LinkText = cat.ThirdLevCategoryName,
        //            Href = "/" + linkPrefix + "/" + cat.CategoryUrl + "/" + cat.SecondLevCategoryUrl + "/" + cat.ThirdLevCategoryUrl,
        //            Title = cat.ThirdLevCategoryName,
        //            SubLinks = la.RelatedArticleLinks(cat, linkPrefix, 3)
        //        };
        //        //linkList[0].SubLinks=la.RelatedArticleLinks(cat, linkPrefix, 3);
        //        List<Category> secondLevelCats = AppStatic.Categories
        //                                        .Where(c => c.SecondLevCategoryId == cat.SecondLevCategoryId
        //                                        && c.CategoryRowId != categoryRowId).ToList();
        //        foreach (Category _cat in secondLevelCats)
        //        {
        //            //linkList.Add(new CustomHtmlLink
        //            //{
        //            //    LinkText = _cat.SecondLevCategoryName,
        //            //    Href = "/" + linkPrefix + "/" + _cat.CategoryUrl + "/" + _cat.SecondLevCategoryUrl,
        //            //    Title = _cat.SecondLevCategoryName + "-category",
        //            //});
        //            //(!String.IsNullOrEmpty(_cat.ThirdLevCategoryUrl))
        //            //{
        //            //}
        //            //linkList.Last().SubLinks = la.RelatedArticleLinks(_cat, linkPrefix);
        //        }
        //        return linkList;
        //    }
        //    if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl))
        //    {
        //        List<Category> secondLevelCats = AppStatic.Categories
        //                                        .Where(c => c.CategoryId == cat.CategoryId).ToList();
        //        foreach (Category _cat in secondLevelCats)
        //        {
        //            linkList.Add(new CustomHtmlLink
        //            {
        //                LinkText = _cat.CategoryName,
        //                Href = "/" + linkPrefix + "/" + _cat.CategoryUrl,
        //                Title = _cat.CategoryName
        //            });
        //            if (!String.IsNullOrEmpty(_cat.ThirdLevCategoryUrl))
        //            {
        //                linkList.Last().SubLinks = GenerateRelatedTreeView(_cat.CategoryRowId, linkPrefix);
        //            }
        //            else
        //            {
        //                linkList.Last().SubLinks = la.RelatedArticleLinks(_cat, linkPrefix, 3);
        //            }
        //        }
        //        return linkList;
        //    }
        //    //ListAccess la = new ListAccess();
        //    //linkList = la.RelatedLinks(cat, linkPrefix);
        //    return linkList;
        //}
        public static List<CustomHtmlLink> GenerateTreeViewThirdLev(Category cat, string linkPrefix)
        {
            List<CustomHtmlLink> linkList = new List<CustomHtmlLink>();
            //ListAccess la = new ListAccess();

            List<Category> thirdLevCats = AppStatic.Categories
                                                .Where(c => c.SecondLevCategoryId == cat.SecondLevCategoryId
                                                && c.ThirdLevCategoryId > 0)
                                                .ToList();
            //List<Category> thirdLevelCats = AppStatic.Categories
            //                                    .Where(c => c.SecondLevCategoryId == cat.SecondLevCategoryId
            //                                     && !String.IsNullOrEmpty(c.ThirdLevCategoryName))
            //                                    .ToList();

            foreach (Category _thirdLevCat in thirdLevCats)
            {
                CustomHtmlLink newCat = new CustomHtmlLink
                        {
                            LinkText = _thirdLevCat.ThirdLevCategoryName,
                            Href = AppStatic.BaseSiteUrl + linkPrefix + "/" + _thirdLevCat.CategoryUrl + "/" + _thirdLevCat.SecondLevCategoryUrl + "/" + _thirdLevCat.ThirdLevCategoryUrl,
                            Title = _thirdLevCat.ThirdLevCategoryName,
                            SubLinks = RelatedArticleLinks(_thirdLevCat, AppStatic.BaseSiteUrl + linkPrefix, 3)
                        };
                newCat.SubLinks.AddRange(RelatedArticleLinks(_thirdLevCat, AppStatic.BaseSiteUrl + linkPrefix, 2));

                linkList.Add(newCat);
                //newCat.SubLinks.AddRange(GenerateTreeViewThirdLev(_secondLevCat.SecondLevCategoryId, linkPrefix));
            }

            return linkList;
        }
Ejemplo n.º 12
0
 public static List<CustomHtmlLink> TreeView(Category cat, string linkPrefix)
 {
     //try
     //{
         List<Category> catList = null;
         //START WITH SECOND LEVEL
         if (cat.SecondLevCategoryId > 0 && cat.ThirdLevCategoryId == 0){
             catList = StaticConfig.Categories.Where(c => c.CategoryId == cat.CategoryId && c.SecondLevCategoryId > 0 && c.ThirdLevCategoryId == 0).ToList();
         }else if (cat.ThirdLevCategoryId >0 ){
             catList = StaticConfig.Categories.Where(c => c.SecondLevCategoryId == cat.SecondLevCategoryId && c.ThirdLevCategoryId == 0).ToList();
         }else{
             catList = StaticConfig.Categories.Where(c => c.CategoryId == cat.CategoryId && c.SecondLevCategoryId == 0).ToList();
         }
         return TreeView(catList, linkPrefix);
         //string href = "";
         //string linkText = "";
         //List<Category> nextCatList = new List<Category>();
         //foreach (Category catItem in catList)
         //{
         //    href = StaticConfig.BaseSiteUrl + linkPrefix + "/";
         //    if (!String.IsNullOrEmpty(catItem.CategoryUrl))
         //    {
         //        href += catItem.CategoryUrl + "/";
         //        linkText = catItem.CategoryName;
         //       // nextCatList = StaticConfig.Categories.Where(c => c.CategoryId == catItem.CategoryId && c != catItem).ToList();
         //    }
         //    if (!String.IsNullOrEmpty(catItem.SecondLevCategoryUrl))
         //    {
         //        href += catItem.SecondLevCategoryUrl + "/";
         //        linkText = catItem.SecondLevCategoryName;
         //        //nextCatList = StaticConfig.Categories.Where(c => c.CategoryId == catItem.CategoryId && c.SecondLevCategoryId == catItem.SecondLevCategoryId && c != catItem).ToList();
         //    }
         //    if (!String.IsNullOrEmpty(catItem.ThirdLevCategoryUrl))
         //    {
         //        href += catItem.ThirdLevCategoryUrl + "/";
         //        linkText = catItem.ThirdLevCategoryName;
         //        //nextCatList = null;
         //    }
         //    if (nextCatList != null)
         //    {
         //        treeLinks.Add(new CustomHtmlLink
         //        {
         //            LinkText = linkText,
         //            Href = href,
         //            Title = linkText,
         //            SubLinks = TreeView(catItem, linkPrefix, treeLinks)
         //        });
         //    }
         //    else
         //    {
         //        treeLinks.Add(new CustomHtmlLink
         //        {
         //            LinkText = linkText,
         //            Href = href,
         //            Title = linkText
         //        });
         //    }
             //foreach (string f in Directory.GetFiles(d))
             //{
             //    Console.WriteLine(f);
             //}
             //DirSearch(d);
        // }
     //}
     //catch (System.Exception excpt)
     //{
     //    Console.WriteLine(excpt.Message);
     //}
 }