Esempio n. 1
0
        //修改
        static void UpdatePosts()
        {
            QueryBlog();


            BlogBusinessLayera bbl = new BlogBusinessLayera();

            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);
        }
Esempio n. 2
0
        static void Delete()
        {
            BlogBusinessLayera bbl = new BlogBusinessLayera();

            Console.WriteLine("请输入id");
            int  id   = int.Parse(Console.ReadLine());
            Blog blog = bbl.Query(id);

            bbl.Delete(blog);
        }
Esempio n. 3
0
        static void QueryBlog()
        {
            BlogBusinessLayera bbl = new BlogBusinessLayera();
            var blogs = bbl.Query();

            foreach (var itme in blogs)
            {
                Console.WriteLine(itme.BlogId + "" + itme.Name);
            }
        }
Esempio n. 4
0
        static void createBlog()
        {
            Console.WriteLine("输入博客名称");
            string name = Console.ReadLine();
            Blog   blog = new Blog();

            blog.Name = name;
            BlogBusinessLayera bll = new BlogBusinessLayera();

            bll.Add(blog);
        }
Esempio n. 5
0
        //查询帖子
        static void ListPost()
        {
            Console.WriteLine("请输入要查找的帖子名字");
            string             title = Console.ReadLine();
            BlogBusinessLayera bbl   = new BlogBusinessLayera();
            var query = bbl.QueryPosts(title);

            foreach (var item in query)
            {
                Console.WriteLine(item.Title + item.Content);
            }
        }
Esempio n. 6
0
        ////查询博客名称
        static void ListBolg()
        {
            Console.WriteLine("请输入要查找的博客名字");
            string             name = Console.ReadLine();
            BlogBusinessLayera bbl  = new BlogBusinessLayera();
            var query = bbl.QueryBlog(name);

            foreach (var item in query)
            {
                Console.WriteLine(item.BlogId + item.Name);
            }
        }
Esempio n. 7
0
        static void Update()
        {
            Console.WriteLine("请输入id");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayera bbl = new BlogBusinessLayera();
            Blog blog = bbl.Query(id);

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

            blog.Name = name;
            bbl.Update(blog);
        }
Esempio n. 8
0
        static void DisplayPosts(int blogId)
        {
            {
                BlogBusinessLayera bbl = new BlogBusinessLayera();
                Blog blog = bbl.Query(blogId);

                List <Post> postList = bbl.PostQuery(blogId);
                foreach (var item in postList)
                {
                    Console.WriteLine("--博客ID:{0}--  ---帖子题目:{1}--  ---帖子内容:{2}--  ---帖子ID:{3}--", item.BlogId, item.Title, item.Content, item.PostId);
                }
            }
        }
Esempio n. 9
0
        //删除帖子
        static void DeletePosts()
        {
            BlogBusinessLayera bbl = new BlogBusinessLayera();

            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);
        }
Esempio n. 10
0
        static void PostById(int blogId)
        {
            Console.WriteLine("请输入id");
            //获取用户输入,并存入变量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  = blogId;
            post.Title   = title;
            post.Content = content;

            BlogBusinessLayera bll = new BlogBusinessLayera();

            bll.PostAdd(post);
        }