public async Task <IActionResult> TwilioCallback([FromForm] TwilioCallbackModel model) { if (model == null) { return(Ok()); } _log.WriteInfo(nameof(TwilioCallback), model.Sanitize(), "Twilio callback"); if (!string.IsNullOrEmpty(model.MessageSid)) { var sms = await _smsRepository.GetByMessageIdAsync(model.MessageSid); if (sms == null) { _log.WriteInfo(nameof(TwilioCallback), model.MessageSid, $"Sms message with messageId = {model.MessageSid} not found"); return(Ok()); } switch (model.MessageStatus) { case TwilioMessageStatus.Delivered: _cqrsEngine.SendCommand(new SmsDeliveredCommand { Message = sms }, "sms", "sms"); break; case TwilioMessageStatus.Failed: case TwilioMessageStatus.Undelivered: _cqrsEngine.SendCommand(new SmsNotDeliveredCommand { Message = sms, Error = $"status = {model.MessageStatus}" }, "sms", "sms"); break; default: _log.WriteWarning(nameof(TwilioCallback), model.MessageSid, $"status = {model.MessageStatus}, callback processing is skipped"); break; } } return(Ok()); }