コード例 #1
0
        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));
        }
コード例 #2
0
        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));
            }
        }