コード例 #1
0
ファイル: Index.cshtml.cs プロジェクト: CDU55/TSP.NET
        public async Task OnGetAsync()
        {
            var posts = await pcc.GetAllPostsAsync();

            foreach (var item in posts)
            {
                // Trebuia folosit AutoMapper. Transform Post in PostDTO
                PostDTO pd = new PostDTO();
                pd.Description = item.Description;
                pd.PostId      = item.PostId;
                pd.Domain      = item.Domain;
                pd.Comments    = new List <CommentDTO>();
                foreach (var cc in item.Comments)
                {
                    CommentDTO cdto = new CommentDTO();
                    cdto.PostPostId = cc.PostPostId;
                    cdto.Text       = cc.Text;
                    pd.Comments.Add(cdto);
                }
                Posts.Add(pd);
            }
        }
コード例 #2
0
        public async Task OnGetAsync()
        {
            PostCommentClient pcc = new PostCommentClient();

            /*var posts = await pcc.GetAllPostsAsync();
             * foreach (var item in posts)
             * {
             *
             *  PostDTO pd = new PostDTO();
             *  pd.Description = item.Description;
             *  pd.PostId = item.PostId;
             *  pd.Domain = item.Domain;
             *
             *  foreach (var cc in item.Comments)
             *  {
             *      CommentDTO cdto = new CommentDTO();
             *      cdto.PostPostId = cc.PostPostId;
             *      cdto.Text = cc.Text;
             *      pd.Comments.Add(cdto);
             *  }
             *  Posts.Add(pd);
             * }*/
            Posts = await pcc.GetAllPostsAsync();
        }