public string NewPost(string blogid, string username, string password, Post post, bool publish) { Thread.Sleep(1000); var newPost = dbContext.Posts.Add(ToPost(post)); dbContext.SaveChanges(); return newPost.Id.ToString(); }
BlogPost ToPost(Post post) { return new BlogPost { Id = post.postid == null ? 0 : int.Parse(post.postid), Title = post.title, Description = post.description, DateCreated = post.dateCreated }; }
public bool EditPost(string postid, string username, string password, Post post, bool publish) { Thread.Sleep(1000); var newPost = dbContext.Posts.Find(int.Parse(postid)); newPost.Title = post.title; newPost.Categories = post.categories; newPost.DateCreated = post.dateCreated; newPost.Description = post.description; dbContext.SaveChanges(); return true; }