Exemplo n.º 1
0
        //Method Post use to active/de-active one service
        public static async Task <bool> PostServiceHandle(DeactiveRequest request, string handle)
        {
            string api = "/api/service/" + handle;

            try
            {
                HttpClient client = new HttpClient();
                client = RestAPI.Get_HttpClient_Token();

                var response = new HttpResponseMessage();

                response = await client.PostAsJsonAsync(api, request).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
        private async void btn_enable_Click(object sender, RoutedEventArgs e)
        {
            progress_bar.Visibility  = Visibility.Visible;
            progress_bar2.Visibility = Visibility.Visible;

            DataGridCellInfo temp    = list_servicenotactive.SelectedCells[0];
            Service_DTO      service = temp.Item as Service_DTO;

            string outlet_name = cb_outlet.SelectedItem.ToString();
            int    outlet_id   = -1;

            foreach (Outlet_DTO temp1 in list)
            {
                if (temp1.outlet_name == outlet_name)
                {
                    outlet_id = temp1.outlet_id;
                    break;
                }
            }

            DeactiveRequest deactive = new DeactiveRequest();

            deactive.service_id = service.service_id;
            deactive.outlet_id  = outlet_id;

            bool result = await RestAPI.PostServiceHandle(deactive, "active");

            Start_State(cb_outlet.SelectedIndex);
        }