コード例 #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
        //修改贴纸

        static void UpdatePost()
        {
            QueryBlog();
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            PostBusinessLayer pbl = new PostBusinessLayer();

            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.UpdatePost(post);
            DisplayPosts(blogId);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: 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();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: HCJ98/End
        //增加贴子
        static void AddPost()
        {
            //显示博客列表
            QueryBlog();
            //用户选择某个博客(id)
            int blogID = GetBlogId();

            //显示指定博客的帖子列表
            DisplayPost(blogID);
            //根据指定到博客信息创建新帖子
            //CreatePost(blogID);

            Post post = new Post();

            post.BlogID = blogID;

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

            post.Title = title;

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

            post.Content = content;

            PostBusinessLayer pbl = new PostBusinessLayer();

            pbl.Add(post);
            Console.Clear();
            selectPost();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: pickJasmin/MVC
        static void SelectPost()
        {
            Console.WriteLine("请输入你要查询的帖子");
            string            name = Console.ReadLine();
            PostBusinessLayer pbl  = new PostBusinessLayer();
            var query = pbl.SelectPostTitle(name);

            foreach (var item in query)
            {
                Console.WriteLine(item.Title + "    " + item.Content);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: 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("");
            }
        }
コード例 #7
0
        /// <summary>
        /// 添加帖子
        /// </summary>
        static void AddPost(int blogId)
        {
            //根据指定到博客信息创建新帖子
            Post post = new Post();

            Console.WriteLine("请输入将要添加的帖子标题");
            post.Title = Console.ReadLine();
            Console.WriteLine("请输入将要添加的帖子内容");
            post.Content = Console.ReadLine();
            post.BlogId  = blogId;
            PostBusinessLayer pbl = new PostBusinessLayer();

            pbl.Add(post);
            //显示指定博客的帖子列表
            DisplayPosts(blogId);
        }
コード例 #8
0
        //删除某个贴纸
        static void DeletePost()
        {
            //显示博客列表
            QueryBlog();
            PostBusinessLayer pbl = new PostBusinessLayer();

            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);

            pbl.DeletePost(post);
            //显示指定博客的帖子列表
            DisplayPosts(blogId);
        }
コード例 #9
0
        //删除帖子
        static void DeletePost()
        {
            QueryBlog();

            BlogBusinessLayer bbl = new BlogBusinessLayer();
            PostBusinessLayer pbl = new PostBusinessLayer();

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

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

            pbl.DeletePost(post);
            DisplayPosts(blogID);
        }
コード例 #10
0
        static void AddPost()
        {
            //显示博客列表
            //QueryBlog();
            //用户选择某个博客(id)
            //int blogId = GetBlogId();
            //Console.WriteLine(blogId);
            //显示指定博客的帖子列表
            // DisplatPosts(blogId);
            //根据指定到博客信息创建新帖子

            //新建帖子
            //填写帖子属性
            //帖子通过数据库上下新增
            Console.WriteLine("请输入id");
            int blogId = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入将要添加的帖子标题");
            string title = Console.ReadLine();

            Console.WriteLine("请输入将要添加的帖子内容");
            string content = Console.ReadLine();
            Post   post    = new Post();

            post.Title   = title;
            post.Content = content;
            post.BlogId  = blogId;
            PostBusinessLayer pbl = new PostBusinessLayer();

            pbl.Add(post);



            //显示指定博客的帖子列表
            //QueryBlog();
            //
            //DeletePost();
            //UpdatePost();
            //删除


            //更新
        }
コード例 #11
0
        static void DeletePost()
        {
            //QueryBlog();

            PostBusinessLayer pbl = new PostBusinessLayer();

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

            DisplatPosts(blogId);
            Console.WriteLine("请输入想要删除的帖子");
            int  postId = int.Parse(Console.ReadLine());
            Post post   = pbl.QueryPost(postId);

            post.BlogId = blogId;
            post.PostId = postId;
            pbl.DeletePost(post);
            DisplatPosts(blogId);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: 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();
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: pickJasmin/MVC
        /// <summary>
        /// 显示添加某个博客的帖子
        /// </summary>
        static void CratePost()
        {
            Post post = new Post();

            Console.WriteLine("请用户输入ID");
            post.BlogId = int.Parse(Console.ReadLine());

            Console.WriteLine("请用户输入标题");
            post.Title = Console.ReadLine();

            Console.WriteLine("请用户输入内容");
            post.Content = Console.ReadLine();
            PostBusinessLayer pbl = new PostBusinessLayer();

            pbl.Add(post);
            DisplayBlogIdByPost(post.BlogId);

            ////显示博客列表
            //QueryBlog();
            ////用户选择某个博客(id)
            //int blogId = GetBlogId();
            ////显示指定博客的帖子列表
            //DisplayBlogIdByPost(blogId);
            ////根据指定到博客信息创建新帖子
            ////新建帖子
            //Post post = new Post();
            ////填写帖子的属性
            //Console.WriteLine("请输入帖子标题");
            //post.Title = Console.ReadLine();
            //Console.WriteLine("请输入帖子内容");
            //post.Content = Console.ReadLine();
            //post.BlogId = blogId;
            ////帖子通过数据库上下文新增
            //using (var db = new BloggingContext())
            //{
            //    db.Posts.Add(post);
            //    db.SaveChanges();
            //}
            ////显示指定博客的帖子列表
            //DisplayBlogIdByPost(blogId);
        }
コード例 #14
0
        static void UpdatePost()
        {
            //QueryBlog();
            int blogId = GetBlogId();

            DisplatPosts(blogId);
            Console.WriteLine("请输入要更改的帖子Id");
            int id = int.Parse(Console.ReadLine());
            PostBusinessLayer pbl = new PostBusinessLayer();
            Post post             = pbl.QueryPost(id);

            Console.WriteLine("请输入新标题");
            string title = Console.ReadLine();

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

            post.Title   = title;
            post.Content = content;
            pbl.Update(post);
            DisplatPosts(blogId);
        }
コード例 #15
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("删除成功!");
        }
コード例 #16
0
        /// <summary>
        /// 修改帖子
        /// </summary>
        static void UpdatePost(int blogId)
        {
            Console.WriteLine("请输入将要更改的帖子id");
            //获取输入并检测输入的帖子ID是否为正整数
            string idStr = PositiveWholeNumberDetection();
            int    id    = int.Parse(idStr);

            //检测帖子ID是否存在
            id = PostIdDetection(idStr, id);

            PostBusinessLayer pbl = new PostBusinessLayer();
            Post post             = pbl.QueryPost(id);

            Console.WriteLine("请输入新标题");
            string title = Console.ReadLine();

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

            post.Title   = title;
            post.Content = content;
            pbl.Update(post);
        }
コード例 #17
0
 public BusinessLogicTests()
 {
     mockPostRepository = new Mock <IPostRepository>();
     adminBusinessLayer = new AdminBusinessLayer(mockPostRepository.Object);
     postBusinessLayer  = new PostBusinessLayer(mockPostRepository.Object);
 }