public async ValueTask <GenericCommandResult> Handle(PostSendSmsCommmandInput command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Incorrect data!", null, StatusCodes.Status400BadRequest, command.Notifications)); } return(new GenericCommandResult(true, "Your SMS sent successfully!", null, StatusCodes.Status200OK, command.Notifications)); }
public async ValueTask <IActionResult> SendSms(PostSendSmsCommmandInput command, [FromServices] NotificationHandler handler) { try { var result = await handler.Handle(command); return(GetResult(result)); } catch (Exception exception) { _logger.LogError("An exception has occurred at {dateTime}. " + "Exception message: {message}." + "Exception Trace: {trace}", DateTime.UtcNow, exception.Message, exception.StackTrace); return(StatusCode(StatusCodes.Status500InternalServerError)); } }