Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public async Task <GetPlantTypeResponse> GetPlantTypes()
        {
            GenericGetRequest    request  = new GenericGetRequest("GetPlantTypes", String.Empty, 0);
            GetPlantTypeResponse response = await GetRequest <GetPlantTypeResponse>(request);

            return(response);
        }
Exemplo n.º 3
0
        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);
            });
        }
Exemplo n.º 5
0
        public async Task <GetPlantTypeResponse> GetPlantTypes(GenericGetRequest request)
        {
            GetPlantTypeResponse response = await GetRequest <GetPlantTypeResponse>(request);

            return(response);
        }