public static List<ServiceArticle> GetSubArticlesById(int _id)
 {
     dbContext = new TeachinVietnamDataContext();
     var list = dbContext.proc_service_article_GetSubArtiles(_id);
     List<ServiceArticle> saList = new List<ServiceArticle>();
     foreach (var article in list)
     {
         ServiceArticle sa = new ServiceArticle();
         sa.id = article.id;
         sa.parentId = Convert.ToInt32(article.parentId);
         sa.title = article.title;
         sa.mainContent = article.maincontent.Replace(Environment.NewLine, "<br />");
         sa.createdDate = (DateTime)article.createdDate;
         sa.displayOnMenu = (bool)article.displayOnMenu;
         sa.DisplayOrder = Convert.ToInt32(article.displayOrder);
         sa.active = (bool)article.active;
         saList.Add(sa);
     }
     return saList;
 }
 public static List<ServiceArticle> GetAll()
 {
     dbContext = new TeachinVietnamDataContext();
     var allArticles = dbContext.tbl_service_articles.Where(x => x.active == true).OrderByDescending(x => x.displayOrder).ThenByDescending(x => x.createdDate).ToList();
     List<ServiceArticle> saList = new List<ServiceArticle>();
     foreach (var article in allArticles)
     {
         ServiceArticle sa = new ServiceArticle();
         sa.id = article.id;
         sa.parentId = Convert.ToInt32(article.parentId);
         sa.title = article.title;
         sa.mainContent = article.maincontent.Replace(Environment.NewLine, "<br />");
         sa.createdDate = (DateTime)article.createdDate;
         sa.displayOnMenu = (bool)article.displayOnMenu;
         sa.DisplayOrder = Convert.ToInt32(article.displayOrder);
         sa.active = (bool)article.active;
         saList.Add(sa);
     }
     return saList;
 }
 public static ServiceArticle GetArticleById(int id)
 {
     dbContext = new TeachinVietnamDataContext();
     proc_service_article_getArticleByIdResult article = dbContext.proc_service_article_getArticleById(id).FirstOrDefault();
     if (article != null)
     {
         ServiceArticle sa = new ServiceArticle();
         sa.id = article.id;
         sa.parentId = Convert.ToInt32(article.parentId);
         sa.title = article.title;
         sa.mainContent = article.maincontent.Replace(Environment.NewLine, "<br />");
         sa.createdDate = (DateTime)article.createdDate;
         sa.DisplayOrder =Convert.ToInt32(article.displayOrder);
         sa.displayOnMenu = (bool)article.displayOnMenu;
         sa.active = (bool)article.active;
         return sa;
     }
     return null;
 }