public async Task CreateThreadAndMessage(MessageDetails details)
        {
            var userEmail = await _userService.GetCurrentUserEmail();

            var recievedBy = _userService.GetUserEmailById(details.RecievedBy.ToString());

            var thread = await _threadRepository.AddThread(MessageDetails.FormThread(details, recievedBy), userEmail);

            await _messageRepository.AddMessage(MessageDetails.FormMessage(details, thread.Id), userEmail);
        }
        public IActionResult CreateThread(int docId, [FromBody] ThreadToCreateDto thread)
        {
            if (thread == null)
            {
                return(BadRequest());
            }
            thread.DocumentId = docId;
            var mappedThread = _mapper.Map <Thread>(thread);

            _threadRepo.AddThread(mappedThread);
            if (!_threadRepo.Save())
            {
                return(StatusCode(500));
            }

            var eventMessage = new ThreadUpdateIntegrationEvent(thread.DocumentId);

            _eventBus.Publish(eventMessage);

            return(StatusCode(201));
        }