Exemplo n.º 1
0
        private async Task <IList <ReplyViewModel> > LoadReplyListAsync(long topicId)
        {
            var list = await _replyService.GetListByTopicIdAsync(topicId);

            var result = list.Select(t => t.ToModel()).ToList();

            foreach (var item in result)
            {
                if (item.ParentId > 0)
                {
                    var parent = result.FirstOrDefault(t => t.Id == item.ParentId);
                    if (parent != null)
                    {
                        item.ParentUserId = parent.UserId;
                        item.ParentUser   = parent.User;
                    }
                }
            }

            return(result);
        }