Example #1
0
 public void DeletePost(Post post)
 {
     using (DomainContext context = new DomainContext())
     {
         context.Posts.Attach(post);
         context.Posts.Remove(post);
         context.SaveChanges();
     }
 }
Example #2
0
 public void UpdatePost(Post post)
 {
     using (DomainContext context = new DomainContext())
     {
         context.Posts.Attach(post);
         context.Entry(post).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #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;
        }
Example #4
0
 public PostModel()
 {
     thePost = new Post();
 }
Example #5
0
 public PostModel(Post post)
 {
     thePost = post;
 }