public bool UpdateComment(int id, CommentTagModel commentTag) { if (!ModelState.IsValid) { return(false); } if (Db.CommentTags.Any(ct => ct.Id == id)) { try { var updatedCommentTag = new CommentTag() { Id = id, FK_TagId = commentTag.FK_TagId, FK_CommentId = commentTag.FK_CommentId }; Db.CommentTags.Update(updatedCommentTag); Db.SaveChanges(); } catch (Exception ex) { return(false); } } return(true); }
public bool SaveComment(CommentTagModel commentTag) { // TODO! Need to bring the user and article/post id to presist comment if (!ModelState.IsValid) { return(false); } try { CommentTag newCommentTag = new CommentTag() { FK_CommentId = commentTag.FK_CommentId, FK_TagId = commentTag.FK_TagId }; Db.Add <CommentTag>(newCommentTag); Db.SaveChanges(); } catch (Exception ex) { return(false); } return(true); }