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()); }
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"); }