Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 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);
     }
 }