public ActionResult <object> InitializeSameAddress(InitializeSameAddressRequest request) { if (ModelState.IsValid) { return(Initialize(() => { _logger.LogInformation("New order initialization using equal billing and shipping addresses."); return new { orderId = _orderService.Initialize(request.Client, request.Address, request.PaymentMethod, request.CurrencyCode, request.DiscountRate) }; })); } _logger.LogWarning("Validation errors detected: {0}", GetValidationMessages()); return(BadRequest(GetValidationMessages())); }
public int InitializeSameAddress(InitializeSameAddressRequest initValues) { var validationResult = _validation.Validate(initValues); int orderId = -1; if (validationResult.isValid) { var response = _restClient.PostAsJsonAsync <InitializeSameAddressRequest>(_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); }