Ejemplo n.º 1
0
        public static MvcHtmlString ArticleLink(this HtmlHelper helper, DIYFE.EF.Article article, string styleClass, string linkText)
        {
            //NOTE: THERE IS A BETTER WAY TO DO THIS...I'M BUSY...SORRY
            try
            {
                if (article.Category == null)
                {
                }
            }
            catch (Exception ex)
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    article.Category = db.Categories.Where(c => c.CategoryRowId == article.CategoryRowId).FirstOrDefault();
                }
            }

            //TODO:the article type is required to build the URL, not bothered by loading it or checking for it...could probably use a enum
            string articleType = "";

            switch (article.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 = "<a class=\"" + styleClass + "\" href=\"" + StaticConfig.BaseSiteUrl + articleType + article.Category.CategoryUrl + "/";

            //MvcHtmlString ahref = new MvcHtmlString("<a href=\"" + StaticConfig.BaseSiteUrl + article.Category.CategoryUrl + "/");
            if (!String.IsNullOrEmpty(article.Category.SecondLevCategoryUrl))
            {
                ahref += article.Category.SecondLevCategoryUrl + "/";
            }
            if (!String.IsNullOrEmpty(article.Category.ThirdLevCategoryUrl))
            {
                ahref += article.Category.ThirdLevCategoryUrl + "/";
            }
            ahref += article.URLLink + "\">" + linkText + "</a>";
            // StaticConfig.BaseSiteUrl + linkPrefix + "/" + cat.CategoryUrl,
            return(new MvcHtmlString(ahref));
        }
Ejemplo n.º 2
0
        public static MvcHtmlString ArticleLink(this HtmlHelper helper, DIYFE.EF.Article article, string styleClass, string linkText)
        {
            //NOTE: THERE IS A BETTER WAY TO DO THIS...I'M BUSY...SORRY
            try
            {
                if (article.Category == null)
                { }
            }
            catch (Exception ex)
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    article.Category = db.Categories.Where(c => c.CategoryRowId == article.CategoryRowId).FirstOrDefault();
                }
            }

            //TODO:the article type is required to build the URL, not bothered by loading it or checking for it...could probably use a enum
            string articleType = "";
            switch (article.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 = "<a class=\"" + styleClass + "\" href=\"" + AppStatic.BaseSiteUrl + articleType + article.Category.CategoryUrl + "/";

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