예제 #1
0
        public async Task Init()
        {
            var list = await _service.GetAll <List <Topic> >(null);

            TopicList.Clear();
            foreach (var topic in list)
            {
                var user = await _userService.GetById <User>(topic.UserId);

                topic.User      = user.FirstName + user.LastName; //User that posted topic
                request.TopicId = topic.Id;
                var _commentList = await _commentService.GetAll <List <Comment> >(request);

                topic.Comments = _commentList.Count;                         // Number of comments
                var _lastComment     = _commentList[_commentList.Count - 1]; // Last comment of topic
                var user_lastComment = await _userService.GetById <User>(_lastComment.UserId);

                topic.LastComment = user_lastComment.FirstName + " " + user_lastComment.LastName;
                TopicList.Add(topic);
            }
        }
예제 #2
0
        public async Task Init()
        {
            if (TopicList.Count > 0)
            {
                TopicList.Clear();
            }
            var list = await _topicService.GetAll <List <Topic> >(null);

            foreach (var topic in list)
            {
                var client = await _userService.GetById <User>(topic.UserID);

                topic.Client    = client.FirstName + " " + client.LastName; //Client that posted topic
                request.TopicID = topic.TopicID;
                var _commentList = await _commentService.GetAll <List <Comment> >(request);

                topic.Comments = _commentList.Count;                           // Number of comments
                var _lastComment       = _commentList[_commentList.Count - 1]; // Last comment of topic
                var client_lastComment = await _userService.GetById <User>(_lastComment.UserID);

                topic.LastComment = client_lastComment.FirstName + " " + client_lastComment.LastName;
                TopicList.Add(topic);
            }
        }