public List <PlantTypeDTO> GetPlantTypes() { List <PlantTypeDTO> plantTypes = new List <PlantTypeDTO>(); try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(((App)App.Current).LAN_Address); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("plain/text")); client.DefaultRequestHeaders.Add("EO-Header", User + " : " + Pwd); HttpResponseMessage httpResponse = client.GetAsync("api/Login/GetPlantTypes").Result; if (httpResponse.IsSuccessStatusCode) { string strData = httpResponse.Content.ReadAsStringAsync().Result; GetPlantTypeResponse response = JsonConvert.DeserializeObject <GetPlantTypeResponse>(strData); plantTypes = response.PlantTypes; } else { MessageBox.Show("There was an error retreiving plant types"); } } catch (Exception ex) { Exception ex2 = new Exception("Admin - GetPlantTypes", ex); ((App)App.Current).LogError(ex2.Message, String.Empty); } return(plantTypes); }
public async Task <GetPlantTypeResponse> GetPlantTypes() { GenericGetRequest request = new GenericGetRequest("GetPlantTypes", String.Empty, 0); GetPlantTypeResponse response = await GetRequest <GetPlantTypeResponse>(request); return(response); }
public void ShowTypes(GetPlantTypeResponse response) { ObservableCollection <KeyValuePair <long, string> > list1 = new ObservableCollection <KeyValuePair <long, string> >(); foreach (PlantTypeDTO code in response.PlantTypes) { list1.Add(new KeyValuePair <long, string>(code.PlantTypeId, code.PlantTypeName)); } Device.BeginInvokeOnMainThread(() => { PlantType.ItemsSource = list1; PlantType.SelectedIndexChanged += PlantType_SelectedIndexChanged; }); LoadSizes(); }
private void PlantTypesLoaded(long inventoryTypeId, ObservableCollection <KeyValuePair <long, string> > list1, GetPlantTypeResponse types) { plantTypes = types.PlantTypes; Device.BeginInvokeOnMainThread(() => { foreach (PlantTypeDTO plantType in plantTypes) { list1.Add(new KeyValuePair <long, string>(plantType.PlantTypeId, plantType.PlantTypeName)); } Type.ItemsSource = list1; LoadListData(inventoryTypeId); }); }
public async Task <GetPlantTypeResponse> GetPlantTypes(GenericGetRequest request) { GetPlantTypeResponse response = await GetRequest <GetPlantTypeResponse>(request); return(response); }