public bool AddComment() { using (ModelPostCommentContainer ctx = new ModelPostCommentContainer()) { bool bResult = false; if (this == null || this.PostPostId == 0) { return(bResult); } if (this.CommentId == 0) { ctx.Entry <Comment>(this).State = EntityState.Added; Post p = ctx.Posts.Find(this.PostPostId); ctx.Entry <Post>(p).State = EntityState.Unchanged; ctx.SaveChanges(); bResult = true; } return(bResult); } }
public bool AddCommentById(int postId, Comment comment) { using (ModelPostCommentContainer ctx = new ModelPostCommentContainer()) { if (comment == null || postId == 0 || comment.Id != 0) { return(false); } comment.PostPostId = postId; ctx.Entry(comment).State = EntityState.Added; Post p = ctx.Posts.Find(postId); ctx.Entry(p).State = EntityState.Unchanged; ctx.SaveChanges(); return(true); } }
public bool AddPost() { using (var ctx = new ModelPostCommentContainer()) { if (PostId == Guid.Empty) { return(false); } ctx.Entry(this).State = EntityState.Added; ctx.SaveChanges(); return(true); } }
public Post AddPost() { using (ModelPostCommentContainer ctx = new ModelPostCommentContainer()) { if (PostId == 0) { ctx.Entry <Post>(this).State = EntityState.Added; ctx.SaveChanges(); } return(this); } }
public bool AddPost() { using (ModelPostCommentContainer context = new ModelPostCommentContainer()) { if (this.PostId == 0) { var it = context.Entry <Post>(this).State = EntityState.Added; context.SaveChanges(); return(true); } return(false); } }
public bool AddPost() { using (ModelPostCommentContainer ctx = new ModelPostCommentContainer()) { bool bResult = false; if (this.PostId == 0) { var it = ctx.Entry <Post>(this).State = EntityState.Added; ctx.SaveChanges(); bResult = true; } return(bResult); } }