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