public Mymodel GetModel1() { string NATIONAL_PARK_API_PATH = BASE_URL + "/323121?"; string parksData = ""; Mymodel parks = null; httpClient.BaseAddress = new Uri(NATIONAL_PARK_API_PATH); // It can take a few requests to get back a prompt response, if the API has not received // calls in the recent past and the server has put the service on hibernation try { HttpResponseMessage response = httpClient.GetAsync(NATIONAL_PARK_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { parksData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!parksData.Equals("")) { // JsonConvert is part of the NewtonSoft.Json Nuget package parks = JsonConvert.DeserializeObject <Mymodel>(parksData); } } catch (Exception e) { // This is a useful place to insert a breakpoint and observe the error message Console.WriteLine(e.Message); } return(parks); }
private void Button_Click(object sender, RoutedEventArgs e) { VM = ServiceLocator.Current.GetInstance <Mymodel>(); Student stu = DataContext as Student; VM.StartTast.Execute(stu.Index); }
public ActionResult Food6() { APIHandler webHandler = new APIHandler(); Mymodel food = webHandler.GetModel6(); return(View(food)); }
// GET: My public ActionResult Index() { var my = new Mymodel { Name = "Стефания", Age = 17 }; ViewBag.My = my; return(View()); }
public ActionResult AboutMe() { var my = new Mymodel { Name = "Афафья", Age = 27 }; ViewBag.Prices = new[] { 100, 120, 140, 99 }; return(View(my)); }