コード例 #1
0
        public async Task <IActionResult> CreateTodo(string todoDescription)
        {
            Devon4NetLogger.Debug("Executing CreateTodo from controller RabbitMqController");

            if (RabbitMqOptions?.Hosts == null || !RabbitMqOptions.Hosts.Any())
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "No RabbitMq instance set up"));
            }

            if (string.IsNullOrEmpty(todoDescription))
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Please provide a valid description for the TO-DO"));
            }

            var todoCommand = new TodoCommand {
                Description = todoDescription
            };
            var published = await TodoRabbitMqHandler.Publish(todoCommand).ConfigureAwait(false);

            return(Ok(published));
        }