Exemple #1
0
 public static bool CreateArticle(DBO.Article article)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Article t_article = new T_Article()
             {
                 id          = article.Id,
                 title       = article.Title,
                 image       = article.Image,
                 category_id = article.CategoryId,
                 text        = article.Text,
                 date        = article.Date,
                 views       = article.Views
             };
             bdd.T_Article.Add(t_article);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Exemple #2
0
 public static bool UpdateArticle(DBO.Article article)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Article t_article = bdd.T_Article.Where(x => x.id == article.Id).FirstOrDefault();
             if (t_article != null)
             {
                 t_article.id          = article.Id;
                 t_article.title       = article.Title;
                 t_article.image       = article.Image;
                 t_article.category_id = article.CategoryId;
                 t_article.text        = article.Text;
                 t_article.date        = article.Date;
                 t_article.views       = article.Views;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }