Beispiel #1
0
 public bool AddComment()
 {
     using (PostCommentContainer ctx = new PostCommentContainer())
     {
         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);
     }
 }
Beispiel #2
0
 public bool AddPost()
 {
     using (PostCommentContainer ctx = new PostCommentContainer())
     {
         bool bResult = false;
         if (this.Id == 0)
         {
             var it = ctx.Entry <Post>(this).State = EntityState.Added;
             ctx.SaveChanges();
             bResult = true;
         }
         return(bResult);
     }
 }