Exemplo n.º 1
0
        public ActionResult <OrderResponse> CreateNewOrder([FromBody] OrderRequest orderRequest)
        {
            if (string.IsNullOrWhiteSpace(orderRequest.Order))
            {
                orderRequest.Order = GetDefaultOrderJson(orderRequest.OrderContent);
            }
            else
            {
                try
                {
                    JsonSerializer.Deserialize <OrderModel>(orderRequest.Order);
                }
                catch (System.Exception)
                {
                    _logger.LogInformation($"Fail to deserialize!");
                    orderRequest.Order = GetDefaultOrderJson(orderRequest.OrderContent);
                }
            }

            var orderResponse = _orderAppService.CreateNewOrder(orderRequest);

            return(CreatedAtRoute("Get", new { jobId = orderResponse.JobId }, orderResponse));
        }