public List <MaterialTypeDTO> GetMaterialTypes() { List <MaterialTypeDTO> materialTypes = new List <MaterialTypeDTO>(); 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/GetMaterialTypes").Result; if (httpResponse.IsSuccessStatusCode) { string strData = httpResponse.Content.ReadAsStringAsync().Result; GetMaterialTypeResponse response = JsonConvert.DeserializeObject <GetMaterialTypeResponse>(strData); materialTypes = response.MaterialTypes; } else { MessageBox.Show("There was an error retreiving material types"); } } catch (Exception ex) { Exception ex2 = new Exception("Admin - GetMaterialTypes", ex); ((App)App.Current).LogError(ex2.Message, String.Empty); } return(materialTypes); }
public async Task <GetMaterialTypeResponse> GetMaterialTypes() { GenericGetRequest request = new GenericGetRequest("GetMaterialTypes", String.Empty, 0); GetMaterialTypeResponse response = await GetRequest <GetMaterialTypeResponse>(request); return(response); }
private void MaterialTypesLoaded(GetMaterialTypeResponse materialTypes) { ObservableCollection <KeyValuePair <long, string> > list1 = new ObservableCollection <KeyValuePair <long, string> >(); foreach (MaterialTypeDTO code in materialTypes.MaterialTypes) { list1.Add(new KeyValuePair <long, string>(code.MaterialTypeId, code.MaterialTypeName)); } Device.BeginInvokeOnMainThread(() => { MaterialType.ItemsSource = list1; MaterialType.SelectedIndexChanged += MaterialType_SelectedIndexChanged; }); }
private void MaterialTypesLoaded(long inventoryTypeId, ObservableCollection <KeyValuePair <long, string> > list1, GetMaterialTypeResponse types) { materialTypes = types.MaterialTypes; Device.BeginInvokeOnMainThread(() => { foreach (MaterialTypeDTO materialType in materialTypes) { list1.Add(new KeyValuePair <long, string>(materialType.MaterialTypeId, materialType.MaterialTypeName)); } Type.ItemsSource = list1; LoadListData(inventoryTypeId); }); }