Exemplo n.º 1
0
        public async Task <IActionResult> SendMessage([FromBody] ChatMessageVm message)
        {
            if (message == null || string.IsNullOrWhiteSpace(message.Message) ||
                string.IsNullOrWhiteSpace(message.FromUser) ||
                string.IsNullOrWhiteSpace(message.ToUser)
                )
            {
                return(BadRequest());
            }

            await repository.SaveMessage(message);

            await messageSender.SendMessage(message.ToPublicMessage());

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task SendMessage(ChatMessageVm message)
        {
            if (message == null || string.IsNullOrWhiteSpace(message.Message) ||
                string.IsNullOrWhiteSpace(message.FromUser) ||
                string.IsNullOrWhiteSpace(message.ToUser)
                )
            {
                logger.LogInformation("Bad request arrived");
                return;
            }

            await repository.SaveMessage(message);

            await messageSender.SendMessage(message.ToPublicMessage());

            logger.LogInformation("Request is processed Ok");
        }