コード例 #1
0
ファイル: Program.cs プロジェクト: pickJasmin/MVC
        /// <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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: M1114378154/Mvc
        //更新贴子
        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);
        }
コード例 #3
0
        //删除
        static void Delete()
        {
            Console.WriteLine("请输入ID");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayer bbl          = new BlogBusinessLayer();
            StudentClass      studentClass = bbl.Query(id);

            bbl.Delete(studentClass);
        }
コード例 #4
0
        //删除博客
        static void Delete()
        {
            Console.WriteLine("请输入ID");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            Blog blog             = bbl.Query(id);

            bbl.Delete(blog);
        }
コード例 #5
0
        //显示全部博客
        static void QueryStudentClass()
        {
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            var blogs             = bbl.Query();

            foreach (var item in blogs)
            {
                Console.WriteLine(item.StudentClassId + " " + item.StudentClassName);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: M1114378154/Mvc
        //显示全部博客
        static void QueryBlog()
        {
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            var blogs             = bbl.Query();

            foreach (var item in blogs)
            {
                Console.WriteLine(item.BlogId + " " + item.Name);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        static void crateBlog()
        {
            Console.WriteLine("请输入一个博客名称");
            string name = Console.ReadLine();
            Blog   blog = new Blog();

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

            bbl.Add(blog);
        }
コード例 #10
0
        static void createStudentClass()
        {
            Console.WriteLine("请输入一个班级的名称");
            string       name = Console.ReadLine();//接收一个用户的名字
            StudentClass blog = new StudentClass();

            blog.StudentClassName = name;
            BlogBusinessLayer bbl = new BlogBusinessLayer();

            bbl.Add(blog);
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        //修改
        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);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: M1114378154/Mvc
        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);
        }
コード例 #14
0
        //显示全部博客
        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);
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: HCJ98/End
        //删除博客
        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();
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: HCJ98/End
        //增加博客
        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();
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: HCJ98/End
        //更新博客
        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();
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: M1114378154/Mvc
        //删除贴子
        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);
        }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: pickJasmin/MVC
        /// <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("删除成功!");
        }