public ActionResult <object> InitializeSeparateAddresses(InitializeSeparateAddressesRequest request)
 {
     if (ModelState.IsValid)
     {
         return(Initialize(() => {
             _logger.LogInformation("New order initialization using separate billing and shipping addresses.");
             return new { orderId = _orderService.Initialize(request.Client, request.ShippingAddress, request.BillingAddress, request.PaymentMethod, request.CurrencyCode, request.DiscountRate) };
         }));
     }
     _logger.LogWarning("Validation errors detected: {0}", GetValidationMessages());
     return(BadRequest(GetValidationMessages()));
 }
        public int InitializeSeparateAddresses(InitializeSeparateAddressesRequest initValues)
        {
            var validationResult = _validation.Validate(initValues);
            int orderId          = -1;

            if (validationResult.isValid)
            {
                var response = _restClient.PostAsJsonAsync <InitializeSeparateAddressesRequest>(_configuration.GetQueryString("InitializeSameAddress", _configuration.GetAPIVersion()), initValues).Result;

                if (response.StatusCode == HttpStatusCode.Created)
                {
                    orderId = JsonConvert.DeserializeObject <dynamic>(response.Content.ReadAsStringAsync().Result).orderId;
                }
                else
                {
                    throw new ArgumentException(response.ReasonPhrase);
                }
            }
            else
            {
                throw new ArgumentException(validationResult.messages);
            }
            return(orderId);
        }