public static bool UpdateComment(DBO.Comment comment) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Comment oldComment = bdd.T_Comment.Where(x => x.id == comment.Id).FirstOrDefault(); oldComment.content = comment.Content; oldComment.id_article = comment.IdArticle; oldComment.id_user = comment.IdUser; oldComment.date = comment.Date; bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateComment(DBO.Comment comment) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Comment newComment = new T_Comment() { content = comment.Content, id_user = comment.IdUser, id_article = comment.IdArticle, date = comment.Date }; bdd.T_Comment.Add(newComment); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }