public List <CommentTreeView> GetChildren(List <CommentTreeView> comments, int parentid)
        {
            var uploadImage = _uploadImageRepository.FindAll();
            var appSettings = _configuaration.GetSection("AppSettings").Get <AppSettings>();

            return(comments
                   .Where(c => c.ParentID == parentid)
                   .Select(c => new CommentTreeView()
            {
                ID = c.ID,
                UserID = c.UserID,
                Username = c.Username,
                Content = c.Content ?? "",
                ImageBase64 = c.ImageBase64,
                ParentID = c.ParentID,
                CreatedTime = c.CreatedTime,
                Seen = c.Seen,
                Level = c.Level,
                Images = uploadImage.Where(x => x.CommentID == c.ID).Select(x => appSettings.applicationUrl + "/images/comments/" + x.Image).ToList() ?? new List <string>(),
                children = GetChildren(comments, c.ID)
            })
                   .OrderByDescending(x => x.CreatedTime)
                   .ToList());
        }
Beispiel #2
0
        public async Task <object> GetAllMessageByRoomAndProject(int roomid)
        {
            var userModel    = _userRepository.FindAll();
            var uploadImages = _uploadImageRepository.FindAll();
            var appSettings  = _configuaration.GetSection("AppSettings").Get <AppSettings>();

            return(await _chatRepository.FindAll().Where(x => x.RoomID.Equals(roomid)).Select(x => new ViewModel.Chat.ChatViewModel
            {
                UserID = x.UserID,
                Message = x.Message,
                CreatedTime = x.CreatedTime,
                RoomID = x.RoomID,
                ProjectID = x.ProjectID,
                ImageBase64 = userModel.FirstOrDefault(_ => _.ID.Equals(x.UserID)).ImageBase64,
                Images = uploadImages.Where(_ => _.ChatID == x.ID).Select(_ => appSettings.applicationUrl + "/images/chats/" + _.Image).ToList(),
                Username = userModel.FirstOrDefault(_ => _.ID.Equals(x.UserID)).Username.ToTitleCase()
            }).ToListAsync());
        }