示例#1
0
 public void DeletePost(Post post)
 {
     using (DomainContext context = new DomainContext())
     {
         context.Posts.Attach(post);
         context.Posts.Remove(post);
         context.SaveChanges();
     }
 }
示例#2
0
 public void UpdatePost(Post post)
 {
     using (DomainContext context = new DomainContext())
     {
         context.Posts.Attach(post);
         context.Entry(post).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#3
0
        public bool AddPost(Post post)
        {
            if (GetPost(post.Title) != null)
            {
                return false;
            }

            using (DomainContext context = new DomainContext())
            {
                context.Posts.Add(post);
                context.SaveChanges();
            }
            return true;
        }
示例#4
0
 public PostModel()
 {
     thePost = new Post();
 }
示例#5
0
 public PostModel(Post post)
 {
     thePost = post;
 }