public Form1() { InitializeComponent(); using (TicketServiceClient client = new TicketServiceClient()) { var tickets = client.GetAll(); listView1.View = View.Details; listView1.FullRowSelect = true; listView1.Columns.Add("Id"); listView1.Columns.Add("EventName"); listView1.Columns.Add("Price"); foreach (var item in tickets) { listView1.Items.Add(new ListViewItem(new string[] { item.Id.ToString(), item.EventName.ToString(), item.Price.ToString() })); } } }
static void Main(string[] args) { TicketServiceClient client = new TicketServiceClient(); var list = client.GetAll(); foreach (var item in list) { Console.WriteLine($"{item.EventName} - {item.Price}"); } //using(var client = new HttpClient()) //{ // client.BaseAddress = new Uri("http://localhost:51477"); // client.DefaultRequestHeaders.Accept.Clear(); // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // //method environment-variables // //var variables = client.GetAsync("environment-variables").Result; // //var deserVariables = JsonConvert.DeserializeObject<IDictionary>(variables.Content.ReadAsStringAsync().Result); // //foreach (var item in deserVariables.Keys) // //{ // // Console.WriteLine($"{item} -- {deserVariables[item]}"); // //} // //method environment-variable/key // //HttpResponseMessage response = client.GetAsync("environment-variable/" + "USERNAME").Result; // //string value = response.Content.ReadAsStringAsync().Result; // //Console.WriteLine(value); //} Console.Read(); }