Esempio n. 1
0
        /// <summary>
        /// 显示所有博客
        /// </summary>
        static void QueryBlog()
        {
            BlogBusinessLayer bbl = new BusinessLayer.BlogBusinessLayer();
            var query             = bbl.Query();

            Console.WriteLine("所有数据库中的博客:");
            foreach (var item in query)
            {
                Console.WriteLine("ID:" + item.BlogId + " Name:" + item.Name);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 删除一个博客
        /// </summary>
        static void Delete()
        {
            Console.WriteLine("请输入将要删除的博客ID");
            //获取输入并检测输入的博客ID是否为正整数
            string idStr = PositiveWholeNumberDetection();
            int    id    = int.Parse(idStr);

            //检测博客ID是否存在
            id = BlogIdDetection(idStr, id);
            BlogBusinessLayer bbl = new BusinessLayer.BlogBusinessLayer();
            Blog blog             = bbl.Query(id);

            bbl.Delete(blog);
        }
Esempio n. 3
0
        /// <summary>
        /// 更改一个博客的名称
        /// </summary>
        static void Update()
        {
            Console.WriteLine("请输入将要更改的博客id");
            //获取输入并检测输入的博客ID是否为正整数
            string idStr = PositiveWholeNumberDetection();
            int    id    = int.Parse(idStr);

            //检测博客ID是否存在
            id = BlogIdDetection(idStr, id);
            BlogBusinessLayer bbl = new BusinessLayer.BlogBusinessLayer();
            Blog blog             = bbl.Query(id);

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

            blog.Name = name;
            bbl.Update(blog);
        }