Esempio n. 1
0
        public static List <Article> DisplayArticles()
        {
            try
            {
                using (var rs = new ArticleDatabaseEntities())
                {
                    var articles = from a in rs.Articles
                                   select a;

                    List <Article> artcleData = articles.ToList();
                    return(artcleData);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public static int UpdateArticleStatus(int id)
        {
            try
            {
                Article articleItem = null;

                using (var rs = new ArticleDatabaseEntities())
                {
                    articleItem = rs.Articles
                                  .Where(o => o.articleId == id)
                                  .FirstOrDefault <Article>();
                    articleItem.isActive        = !articleItem.isActive;
                    rs.Entry(articleItem).State = EntityState.Modified;
                    return(rs.SaveChanges());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }