コード例 #1
0
        public async Task OnGet(int pageIndex = 1, int pageSize = 10)
        {
            this.ArticleModels = await _articleService.GetArticlePageList(new PageingModel()
            {
                PageIndex = pageIndex,
                PageSize  = pageSize
            });

            if (!this.ArticleModels.Any())
            {
                var articleid = Guid.Parse("3A82C623-A6FD-441B-BF89-F0A06B771639");

                var authors = new List <AuthorEntities>()
                {
                    new AuthorEntities()
                    {
                        Id        = Guid.Parse("F7197771-D918-43EC-BF68-B039303313BE"),
                        FirstName = "张",
                        LastName  = "三",
                        ArticelId = articleid
                    }
                };

                var article = new ArticleEntities()
                {
                    Id             = articleid,
                    Title          = "C# 学习指南",
                    Content        = "XXXXXXXXXXXXXXXXXXXXXXXXXx",
                    CreateTime     = DateTime.Now,
                    AuthorEntities = authors
                };

                if (await _articleService.AddArticles(article))
                {
                    Console.WriteLine("添加成功");
                }
            }
        }