public async Task <List <ThreadDetails> > GetThreadsAndMessagesByUserId()
        {
            var currentUserMail = await _userService.GetCurrentUserEmail();

            var threads  = _threadRepository.GetThreadsByUserId(currentUserMail);
            var messages = _messageRepository.GetMessagesByUserId(currentUserMail);

            return(threads.Select(thread => new ThreadDetails
            {
                Id = thread.Id,
                Topic = thread.Topic,
                Messages = messages
                           .Where(message => message.ThreadId == thread.Id)
                           .Select(message => MessageDetails.FormMessageDetails(message)).ToList()
            }).ToList());
        }
 public List <MessageDetails> GetMessagesByThreadId(int threadId)
 {
     return(_messageRepository.GetMessagesByThreadId(threadId).Select(message => MessageDetails.FormMessageDetails(message)).ToList());
 }