//更新贴子 static void UpdatePost() { QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); PostBussinessLayer pbl = new PostBussinessLayer(); Console.WriteLine("请输入一个博客ID"); int blogId = int.Parse(Console.ReadLine()); DisplayPosts(blogId); Console.WriteLine("请输入修改的贴子ID"); int postId = int.Parse(Console.ReadLine()); Post post = pbl.QueryPost(postId); Console.WriteLine("请输入新标题"); string newTitle = Console.ReadLine(); post.Title = newTitle; Console.WriteLine("请输入新内容"); string newContent = Console.ReadLine(); post.Content = newContent; pbl.Update(post); DisplayPosts(blogId); }
static void AddPost() { //显示博客列表 QueryBlog(); //用户选择某个博客(id) int blogId = GetBlogId(); //显示指定博客的帖子列表 DisplatPosts(blogId); //根据指定到博客信息创建新帖子 Console.WriteLine("请输入将要添加的帖子标题"); string title = Console.ReadLine(); Console.WriteLine("请输入将要添加的帖子内容"); string content = Console.ReadLine(); Post post = new Post(); post.Title = title; post.Content = content; post.BlogId = blogId; PostBussinessLayer pbl = new PostBussinessLayer(); pbl.Add(post); //显示指定博客的帖子列表 DisplatPosts(blogId); }
static void postDelete() { PostBussinessLayer bbl = new PostBussinessLayer(); Console.WriteLine("请输入id"); int id = int.Parse(Console.ReadLine()); Post plog = bbl.Query(id); bbl.Delete(plog); }
static void postcreateBlog() { Console.WriteLine("请输入一个帖子名称"); string name = Console.ReadLine(); Post plog = new Post(); plog.Title = name; PostBussinessLayer bbl = new PostBussinessLayer(); bbl.Add(plog); }
//查询贴子 static void SelectPost() { Console.WriteLine("请输入查询的博客贴子"); string names = Console.ReadLine(); PostBussinessLayer pbl = new PostBussinessLayer(); var query = pbl.QueryForTitle(names); foreach (var item in query) { Console.WriteLine(item.Title + " " + item.Content); } }
//删除贴子 static void DeletePost() { QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); PostBussinessLayer pbl = new PostBussinessLayer(); Console.WriteLine("请输入一个博客ID"); int id = int.Parse(Console.ReadLine()); DisplayPosts(id); Console.WriteLine("请输入删除的贴子"); int postId = int.Parse(Console.ReadLine()); Post post = pbl.QueryPost(postId); pbl.DeletePost(post); DisplayPosts(id); }
static void UpdatePost() { QueryBlog(); int blogId = GetBlogId(); DisplatPosts(blogId); Console.WriteLine("请输入要更改的帖子Id"); int id = int.Parse(Console.ReadLine()); PostBussinessLayer pbl = new PostBussinessLayer(); Post post = pbl.QueryPost(id); Console.WriteLine("请输入新标题"); string title = Console.ReadLine(); Console.WriteLine("请输入新的内容"); string content = Console.ReadLine(); post.Title = title; post.Content = content; pbl.Update(post); DisplatPosts(blogId); }