예제 #1
0
        static void UpdatePosts()
        {
            QueryBlog();


            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            Console.WriteLine("请输入一个博客ID");
            int blogID = int.Parse(Console.ReadLine());

            DisplayPosts(blogID);
            Console.WriteLine("请输入要修改的帖子ID");
            int  postID = int.Parse(Console.ReadLine());
            Post post   = bbl.postQuery(postID);

            Console.WriteLine("请输入新题目");
            string newTitle = Console.ReadLine();

            post.Title = newTitle;
            Console.WriteLine("请输入新内容");
            string newContent = Console.ReadLine();

            post.Content = newContent;
            bbl.pUpdate(post);
            DisplayPosts(blogID);
        }
예제 #2
0
        //删除博客
        static void Delete()
        {
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            Console.WriteLine("请输入一个博客ID");
            int  id   = int.Parse(Console.ReadLine());
            Blog blog = bbl.Query(id);

            bbl.Delete(blog);
        }
예제 #3
0
        static void QueryBlog()
        {
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();
            var blogs = bbl.Query();

            foreach (var item in blogs)
            {
                Console.WriteLine(item.BlogId + "" + item.Name);
            }
        }
예제 #4
0
        //新增博客
        static void createBlog()
        {
            Console.WriteLine("请输入一个博客名称");
            string name = Console.ReadLine();
            Blog   blog = new Blog();

            blog.Name = name;
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            bbl.Add(blog);
        }
예제 #5
0
        static void DisplayPosts(int blogID)
        {
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();
            Blog blog = bbl.Query(blogID);

            List <Post> postList = bbl.pQuery(blogID);

            foreach (var item in postList)
            {
                Console.WriteLine("博客ID:{0}  ---  帖子题目:{1}  ---  帖子内容:{2}  ---帖子ID:{3}", item.BlogId, item.Title, item.Content, item.PostId);
            }
        }
예제 #6
0
        //修改博客
        static void Update()
        {
            Console.WriteLine("请输入id");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();
            Blog blog = bbl.Query(id);

            Console.WriteLine("请输入新名字");
            string name = Console.ReadLine();

            blog.Name = name;
            bbl.Update(blog);
        }
예제 #7
0
        //模糊查找
        static void ALLQuery()
        {
            Console.WriteLine("输入博客名称");
            string i = Console.ReadLine();
            BlogBusinessLayerss bbl  = new BlogBusinessLayerss();
            List <Blog>         blog = bbl.ALLQuery(i);

            foreach (var item in blog)
            {
                Console.WriteLine(item.Name);
            }
            Console.ReadKey();
        }
예제 #8
0
        static void MHQuery()
        {
            Console.WriteLine("输入博客名称关键字");
            string i = Console.ReadLine();

            BlogBusinessLayerss bbl = new BlogBusinessLayerss();
            var blog = bbl.mhQuery(i);

            foreach (var item in blog)
            {
                Console.WriteLine("{0}---{1}", item.Name, item.BlogId);
            }
            Console.ReadKey();
        }
예제 #9
0
        //删除帖子
        static void DeletePosts()
        {
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            Console.WriteLine("请输入一个博客ID");
            int blogID = int.Parse(Console.ReadLine());

            DisplayPosts(blogID);
            Console.WriteLine("请输入要删除的帖子ID");
            int  postID = int.Parse(Console.ReadLine());
            Post post   = bbl.postQuery(postID);

            bbl.DeletePost(post);
            DisplayPosts(blogID);
        }
예제 #10
0
        static void CheckPostID(int blogID)
        {
            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            Blog blog = bbl.Query(blogID);

            if (blog == null)
            {
                Console.WriteLine("没有此博客");

                opBlog();
            }
            else
            {
                return;
            }
        }
예제 #11
0
        //新增帖子
        static void CreatNewPosts(int blogid)
        {
            Console.WriteLine("请输入一个博客ID");
            int id = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入一个帖子名称");
            string title = Console.ReadLine();

            Console.WriteLine("请输入一个帖子名称");
            string content = Console.ReadLine();

            Post post = new Post();

            post.BlogId  = id;
            post.Title   = title;
            post.Content = content;

            BlogBusinessLayerss bbl = new BlogBusinessLayerss();

            bbl.pAdd(post);
        }