Пример #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            button              = FindViewById <Button>(Resource.Id.myButton);
            edtIdEleccion       = FindViewById <EditText>(Resource.Id.edtIdEleccion);
            edtNombreRepartidor = FindViewById <EditText>(Resource.Id.edtNombreRepartidor);
            lv = FindViewById <ListView>(Resource.Id.lvPedidos);
            //button.Click += delegate { button.Text = $"{count++} clicks!"; };
            List <string>      nombres = new List <string>();
            List <PedidoModel> json    = await LeerApi();

            for (int i = 0; i < json.Count; i++)
            {
                PedidoModel a = json.ElementAt(i);
                string      nombreCompleto = a.id + " - " + a.telefono;
                nombres.Add(nombreCompleto);
            }
            ArrayAdapter ListAdapter = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, nombres);

            lv.SetAdapter(ListAdapter);
            button.Click += pedir;
        }
Пример #2
0
        public bool Postear(PedidoModel item)
        {
            string baseurl = "http://scmrocket.azurewebsites.net/api/pedidos/" + id.ToString();
            var    Client  = new HttpClient();

            Client.MaxResponseContentBufferSize = 256000;
            var           uril     = new Uri(baseurl);
            var           json     = JsonConvert.SerializeObject(item);
            StringContent content  = new StringContent(json, Encoding.UTF8, "application/json");
            var           response = Client.PutAsync(uril, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }