Esempio n. 1
0
File: Program.cs Progetto: HCJ98/End
        //更新贴子
        static void UpdatePost()
        {
            //显示博客列表
            QueryBlog();
            //用户选择某个博客(id)
            int blogID = GetBlogId();

            //显示指定博客的帖子列表
            DisplayPost(blogID);

            Console.WriteLine("输入需要修改到贴子id");
            int id = int.Parse(Console.ReadLine());
            PostBusinessLayer pbl = new PostBusinessLayer();
            Post post             = pbl.Query(id);

            Console.WriteLine("请输入新的贴子名称");
            string title = Console.ReadLine();

            post.Title = title;

            Console.WriteLine("请输入新的贴子内容");
            string content = Console.ReadLine();

            post.Content = content;

            pbl.Update(post);
            Console.Clear();
            selectPost();
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
File: Program.cs Progetto: HCJ98/End
        //显示全部贴子
        static void QuertPost()
        {
            PostBusinessLayer pbl = new PostBusinessLayer();
            var posts             = pbl.Query();

            foreach (var item in posts)
            {
                Console.WriteLine("博客id:" + item.BlogID);
                Console.WriteLine("贴子id:" + item.PostId);
                Console.WriteLine("贴子名称:" + item.Title);
                Console.WriteLine("贴子内容:" + item.Content);
                Console.WriteLine("");
            }
        }
Esempio n. 4
0
File: Program.cs Progetto: HCJ98/End
        //删除贴子
        static void DeletPost()
        {
            //显示博客列表
            QueryBlog();
            //用户选择某个博客(id)
            int blogID = GetBlogId();

            //显示指定博客的帖子列表
            DisplayPost(blogID);

            PostBusinessLayer pbl = new PostBusinessLayer();

            Console.WriteLine("输入需要删除到贴子id");
            int  id   = int.Parse(Console.ReadLine());
            Post post = pbl.Query(id);

            pbl.Delete(post);
            Console.Clear();
            selectPost();
        }
Esempio n. 5
0
        /// <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("删除成功!");
        }