Ejemplo n.º 1
0
        public async Task <ActionResult <PlaceOrderResponse> > Place([FromBody] PlaceOrderRequest request)
        {
            _logger.LogInformation($"Place order service call for {request.OrderNumber}...");
            var response = new PlaceOrderResponse();

            try
            {
                await _orderProcessingService.PlaceOrderAsync(request.OrderNumber, request.UserId, request.OrderAmount, request.Gateway, request.Description, request.Callback);

                var order = await _orderProcessingService.GetOrderAsync(request.OrderNumber);

                response.Bills.AddRange(order.Bills.Select(x => (BillingInfoDTO)x).ToList());
            }
            catch (ValidationException ex)
            {
                _logger.LogWarning($"Validations failures: {ex.Message}");
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception occured while placing order: {ex.Message} {ex.StackTrace}");
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok(response));
        }