예제 #1
0
 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;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }