public ServiceResult <string> GetOrderRaw(string eventId, string orderId) { try { this.GetClient(); string address = $"/v3/events/{eventId}/orders/?token={this._token}&expand=attendees"; //string str2 = this.client.DownloadString(address); client.BaseAddress = new Uri(this._baseURL); HttpResponseMessage response = client.GetAsync(address).Result; var responseString = response.Content.ReadAsStringAsync().Result; string str3 = ""; OrderResults results = JsonConvert.DeserializeObject <OrderResults>(responseString); OrderResults results2 = new OrderResults { Pagination = results.Pagination }; if (results.Pagination.page_count > 1) { for (int i = 0; i < results.Pagination.page_count; i++) { string address1 = $"/v3/events/{eventId}/orders/?token={this._token}&page={i + 1}&expand=attendees"; //this.client.DownloadString(str4) //client.BaseAddress = new Uri(this._baseURL); HttpResponseMessage response1 = client.GetAsync(address1).Result; var responseString1 = response1.Content.ReadAsStringAsync().Result; OrderResults results3 = JsonConvert.DeserializeObject <OrderResults>(responseString1); foreach (Order order in results3.orders) { if (order.id == orderId) { str3 = JsonConvert.SerializeObject(order); return(new ServiceResult <string>(true, str3, "")); } } } } else { foreach (Order order in results.orders) { if (order.id == orderId) { return(new ServiceResult <string>(true, JsonConvert.SerializeObject(order), "")); } } } return(new ServiceResult <string>(true, "Error", "")); } catch (Exception exception) { this.GetClient(); return(new ServiceResult <string>(false, exception.Message, exception.Message)); } }
public ServiceResult <OrderResults> GetOrders(string eventId) { try { this.GetClient(); string address = $"/v3/events/{eventId}/orders/?token={this._token}&expand=attendees.promotional_code"; //this.client.DownloadString(address) client.BaseAddress = new Uri(this._baseURL); HttpResponseMessage response = client.GetAsync(address).Result; var responseString = response.Content.ReadAsStringAsync().Result; OrderResults results = JsonConvert.DeserializeObject <OrderResults>(responseString); OrderResults results2 = new OrderResults { Pagination = results.Pagination }; if (results.Pagination.page_count > 1) { client.CancelPendingRequests(); for (int i = 0; i < results.Pagination.page_count; i++) { string address1 = $"/v3/events/{eventId}/orders/?token={this._token}&page={i + 1}&expand=attendees.promotional_code"; //this.client.DownloadString(str3) HttpResponseMessage response1 = client.GetAsync(address1).Result; var responseString1 = response1.Content.ReadAsStringAsync().Result; OrderResults results3 = JsonConvert.DeserializeObject <OrderResults>(responseString1); if (results2.orders == null) { results2.orders = new List <Order>(); } if (results3.orders != null) { results2.orders.AddRange(results3.orders); } } } else { results2.orders = results.orders; } return(new ServiceResult <OrderResults>(true, results2, "")); } catch (Exception exception) { this.GetClient(); return(new ServiceResult <OrderResults>(false, new OrderResults(), exception.Message)); } }