Exemple #1
0
        public async Task <ActionResult> Post([FromBody] MessageContent messageModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var messageId     = _messagesRepository.SaveMessage(messageModel.Text);
            var storedMessage = _messagesRepository.GetMessage(messageId);

            var json = JsonConvert.SerializeObject(storedMessage);

            await _webSocketService.SendMessageToAllAsync(json);

            return(Ok());
        }