Example #1
0
 public static bool UpdateComment(DBO.Comment comment)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Comment t_comment = bdd.T_Comment.Where(x => x.id == comment.Id).FirstOrDefault();
             if (t_comment != null)
             {
                 t_comment.id         = comment.Id;
                 t_comment.title      = comment.Title;
                 t_comment.text       = comment.Text;
                 t_comment.article_id = comment.ArticleId;
                 t_comment.user_id    = comment.UserId;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Example #2
0
 public static bool CreateComment(DBO.Comment comment)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Comment t_comment = new T_Comment()
             {
                 id         = comment.Id,
                 title      = comment.Title,
                 text       = comment.Text,
                 article_id = comment.ArticleId,
                 user_id    = comment.UserId
             };
             bdd.T_Comment.Add(t_comment);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }