/// <summary> /// 更改帖子内容 /// </summary> static void UpdatePost() { QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); Console.WriteLine(" 请输入一个博客ID"); int blogID = int.Parse(Console.ReadLine()); DisplayBlogIdByPost(blogID); PostBusinessLayer pbl = new PostBusinessLayer(); Console.WriteLine("请输入您要修改的,帖子的ID:"); int postId = int.Parse(Console.ReadLine()); Post post = pbl.Query(postId); Console.WriteLine("请输入您要修改的标题:"); string postTitle = Console.ReadLine(); post.Title = postTitle; Console.WriteLine("请输入您要修改的内容:"); string postContent = Console.ReadLine(); post.Content = postContent; pbl.Update(post); DisplayBlogIdByPost(blogID); }
//更新贴子 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 Delete() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); StudentClass studentClass = bbl.Query(id); bbl.Delete(studentClass); }
//删除博客 static void Delete() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); bbl.Delete(blog); }
//显示全部博客 static void QueryStudentClass() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var blogs = bbl.Query(); foreach (var item in blogs) { Console.WriteLine(item.StudentClassId + " " + item.StudentClassName); } }
//显示全部博客 static void QueryBlog() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var blogs = bbl.Query(); foreach (var item in blogs) { Console.WriteLine(item.BlogId + " " + item.Name); } }
static void DeletePost() { BlogBusinessLayer bbl = new BlogBusinessLayer(); Console.WriteLine("请输入帖子的id"); int id = int.Parse(Console.ReadLine()); Post post = new Post(); post.PostId = id; bbl.deletepost(post); }
/// <summary> /// 创建一个博客 /// </summary> static void CrateBlog() { Console.WriteLine("请输入将要添加的博客用户名称"); string name = Console.ReadLine(); Blog blog = new Models.Blog(); blog.Name = name; BlogBusinessLayer bbl = new BlogBusinessLayer(); bbl.Add(blog); }
static void crateBlog() { Console.WriteLine("请输入一个博客名称"); string name = Console.ReadLine(); Blog blog = new Blog(); blog.Name = name; BlogBusinessLayer bbl = new BlogBusinessLayer(); bbl.Add(blog); }
static void createStudentClass() { Console.WriteLine("请输入一个班级的名称"); string name = Console.ReadLine();//接收一个用户的名字 StudentClass blog = new StudentClass(); blog.StudentClassName = name; BlogBusinessLayer bbl = new BlogBusinessLayer(); bbl.Add(blog); }
static void SelectBlog() { Console.WriteLine("请输入博客关键字"); string name = Console.ReadLine(); BlogBusinessLayer blg = new BlogBusinessLayer(); var query = blg.Select(name); foreach (var item in query) { Console.WriteLine(item.BlogId + " " + item.Name); } }
//修改 static void Update() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); StudentClass studentClass = bbl.Query(id); Console.WriteLine("请输入新名字"); string name = Console.ReadLine(); studentClass.StudentClassName = name; bbl.Update(studentClass); }
static void Update() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); Console.WriteLine("请输入新名字"); string name = Console.ReadLine(); blog.Name = name; bbl.Update(blog); }
//显示全部博客 static void QueryBlog() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var query = bbl.Query(); Console.WriteLine("所有数据库中的博客"); foreach (var item in query) { Console.Write(item.BlogId + ""); Console.WriteLine(item.Name); } }
//删除博客 static void Delete() { QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); Console.WriteLine("请输入需要删除到博客id"); int id = int.Parse(Console.ReadLine()); Blog blog = bbl.Query(id); bbl.Delete(blog); Console.Clear(); selectBlog(); }
//增加博客 static void createBlog() { QueryBlog(); Console.WriteLine("请输入新的博客名"); string name = Console.ReadLine(); Blog blog = new Blog(); blog.Name = name; BlogBusinessLayer bbl = new BlogBusinessLayer(); bbl.Add(blog); Console.Clear(); selectBlog(); }
static void LinqSelectBlog() { Querypos(); Console.WriteLine("请输入帖子名称"); string name = Console.ReadLine(); BlogBusinessLayer bbl = new BlogBusinessLayer(); var pos = bbl.Querysds(name); foreach (var item in pos) { Console.WriteLine(item.Title + " " + item.Content); } }
//更新博客 static void Update() { QueryBlog(); Console.WriteLine("请输入需要修改的博客id"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); Console.WriteLine("请输入博客新名字"); string name = Console.ReadLine(); blog.Name = name; bbl.Update(blog); Console.Clear(); selectBlog(); }
//删除贴子 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); }
/// <summary> /// 检测博客ID是否存在 /// </summary> /// <returns></returns> static int BlogIdDetection(string idStr, int id) { BlogBusinessLayer bbl = new BlogBusinessLayer(); bool idDetection = true; while (idDetection) { if (bbl.Query(id) == null) { Console.WriteLine("没有该博客ID,请重新输入!"); idStr = PositiveWholeNumberDetection(); id = int.Parse(idStr); } else { idDetection = false; } } return(id); }
/// <summary> /// 删除一个帖子 /// </summary> static void DeletePost() { //显示所有博客列表 QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); Console.WriteLine(" 请输入一个博客ID"); int blogID = int.Parse(Console.ReadLine()); DisplayBlogIdByPost(blogID); PostBusinessLayer pbl = new PostBusinessLayer(); Console.WriteLine("请输入一个帖子的id"); int postid = int.Parse(Console.ReadLine()); Post post = pbl.Query(postid); pbl.Delete(post); Console.WriteLine("删除成功!"); }