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