Exemplo n.º 1
0
        private async Task CancelarServicio(int id)
        {
            btnCancel.IsEnabled = false;
            Cator.IsRunning     = true;
            Cator.IsVisible     = true;
            var msn = Message.Text;

            if (string.IsNullOrEmpty(msn))
            {
                Message.Focus();
            }
            else
            {
                HttpClient client        = new HttpClient();
                var        cancel_values = new Dictionary <string, string> {
                    { "id_solicitud", id.ToString() },
                    { "comentario", msn.ToString() }
                };
                var cancel_content = new FormUrlEncodedContent(cancel_values); //solicitud/agrega

                var cancelpost = await client.PostAsync("http://www.washdryapp.com/app/public/solicitud/cliente_cancelar", cancel_content);

                if (cancelpost.IsSuccessStatusCode)
                {
                    userDataBase = new UserDataBase();
                    userDataBase.DeleteSolicitud(id);


                    await DisplayAlert("Lavado cancelado", "Solicitud de servicio cancelada.", "ok");

                    await PopupNavigation.PopAsync();
                }
                else
                {
                    HttpContent contentx = cancelpost.Content;
                    var         respx    = await contentx.ReadAsStringAsync();

                    await DisplayAlert("Error", "Pudo haber un error. Intente en otro momento . " + respx, "ok");

                    await PopupNavigation.PopAsync();
                }

                await Navigation.PopToRootAsync();
            }

            Cator.IsRunning = false;
            Cator.IsVisible = false;
        }
Exemplo n.º 2
0
        private async void StripeTokenBtn_Clicked(object sender, EventArgs e)
        {
            var Card    = Card_.Text;
            var Monthx  = Month.Text;
            var Yearx   = Year.Text;
            var Secretx = Secret.Text;

            if (string.IsNullOrEmpty(Card))
            {
                Card_.Focus();
            }

            else if (string.IsNullOrEmpty(Monthx))
            {
                Month.Focus();
            }
            else if (string.IsNullOrEmpty(Yearx))
            {
                Year.Focus();
            }

            else if (string.IsNullOrEmpty(Secretx))
            {
                Secret.Focus();
            }
            else
            {
                try
                {
                    Cator.IsVisible = true;
                    Cator.IsRunning = true;
                    userDataBase    = new UserDataBase();
                    var user = userDataBase.GetMembers().ToList();
                    var solx = userDataBase.GetSolicitud(sid).ToList();

                    StripeConfiguration.SetApiKey("pk_test_HQOqIXmo6C3MyZ2h9bBAcWKs00ngt4dRKC");
                    var service      = new ChargeService();
                    var Tokenoptions = new TokenCreateOptions
                    {
                        Card = new CreditCardOptions
                        {
                            Number   = Card,
                            ExpYear  = Int32.Parse(Year.Text),
                            ExpMonth = Int32.Parse(Month.Text),
                            Cvc      = Secret.Text,
                            Name     = user[0].nombre,

                            /*  AddressLine1 = "18",
                             * AddressLine2 = "SpringBoard",
                             * AddressCity = "Gurgoan",
                             * AddressZip = "284005",
                             * AddressState = "Haryana",*/
                            AddressCountry = "Mexico",
                            Currency       = "mxn",
                        }
                    };

                    Tokenservice = new TokenService();
                    stripeToken  = Tokenservice.Create(Tokenoptions);
                    // StripeLbl.Text = stripeToken.Id;


                    HttpClient client      = new HttpClient();
                    var        value_check = new Dictionary <string, string>
                    {
                        { "stripeToken", stripeToken.Id },
                        { "email", user[0].email },
                        { "id_washer", solx[0].id_washer },
                        { "id_solicitud", solx[0].id_solicitud },
                        { "tipo_pago", solx[0].forma_pago },
                        { "id_usuario", solx[0].id_usuario },
                        { "cambio", solx[0].cambio },
                        { "monto", solx[0].precio }
                    };


                    var content  = new FormUrlEncodedContent(value_check);
                    var response = await client.PostAsync("http://www.washdryapp.com/app/public/pagos/generar", content);

                    switch (response.StatusCode)
                    {
                    case System.Net.HttpStatusCode.BadRequest:
                        await DisplayAlert("error", "error status 400 Unauthorized", "ok");

                        break;

                    case System.Net.HttpStatusCode.Forbidden:
                        await DisplayAlert("error", "error status 403  ", "ok");

                        break;

                    case System.Net.HttpStatusCode.NotFound:
                        await DisplayAlert("error", "error status 404  ", "ok");

                        break;

                    case System.Net.HttpStatusCode.OK:
                        await DisplayAlert("Pago exitoso", "Gracias , fue un placer atender su servicio.", "ok");

                        userDataBase.DeleteSolicitud(Int32.Parse(solx[0].id_solicitud));
                        string xjson = await response.Content.ReadAsStringAsync();

                        await PopupNavigation.PopAsync();

                        await Navigation.PushModalAsync(new Calificar(sid));

                        break;


                    case System.Net.HttpStatusCode.RequestEntityTooLarge:
                        await DisplayAlert("error", "error status 413  ", "ok");

                        break;

                    case System.Net.HttpStatusCode.RequestTimeout:
                        await DisplayAlert("error", "error status 408  ", "ok");

                        break;



                    case System.Net.HttpStatusCode.Unauthorized:
                        await DisplayAlert("error", "yeah status 401 Unauthorized", "ok");

                        break;
                    }
                }
                catch (Exception ex)
                {
                    var x = ex.ToString();
                    //  StripeLbl.Text = ex.ToString() ;
                }
            }
            Cator.IsVisible = false;
            Cator.IsRunning = true;
        }
Exemplo n.º 3
0
        private async Task GetSolicitud(int id)
        {
            CatorMain.IsVisible = true;
            CatorMain.IsRunning = true;

            HttpClient client = new HttpClient();
            var        info   = await client.GetAsync("http://washdryapp.com/app/public/solicitud/lista_solicitud/" + id);

            if (info.IsSuccessStatusCode)
            {
                var content = info.Content;
                var json    = await content.ReadAsStringAsync();

                var          xjson = JsonConvert.DeserializeObject <List <Solicitudes> >(json);
                UserDataBase udb   = new UserDataBase();

                if (xjson.Count > 0)
                {
                    lbltitle.Text   = xjson[0].paquete;
                    lbldate.Text    = xjson[0].fecha;
                    lblprecio.Text  = "$ " + xjson[0].precio + " Mxn ";
                    lbldestino.Text = xjson[0].modelo + " " + xjson[0].placas;
                    var status = xjson[0].status;
                    switch (status)
                    {
                    case "1":
                        status = "En proceso";
                        break;

                    case "2":
                        status = "Aceptado";
                        break;

                    case "3":
                        status = "Lavado en proceso";
                        break;

                    case "4":
                        imgxwasher.Source      = xjson[0].foto_washer;
                        imglavado.Source       = xjson[0].foto;
                        imglavado.IsVisible    = true;
                        btnpagartest.IsEnabled = true;
                        btnpagartest.IsVisible = true;
                        imgxwasher.IsVisible   = true;
                        btnCancel.IsVisible    = false;
                        if (xjson[0].forma_pago == "Efectivo")
                        {
                            btnpagartest.IsVisible = false;
                        }
                        status = "En espera de pago";
                        break;

                    case "5":


                        status = "Lavado pagado";
                        break;

                    case "6":
                        udb.DeleteSolicitud(id_lite);
                        status = "Cancelado";
                        break;

                    case "7":
                        udb.DeleteSolicitud(id_lite);
                        btnCancel.IsVisible = false;
                        status = "Terminado";
                        break;
                    }
                    lblstatus.Text = status;

                    if (string.IsNullOrEmpty(xjson[0].foto))
                    {
                        lblimg.IsVisible = true;
                        lblimg.Text      = "Iamgen no disponible";
                    }
                    else
                    {
                        imgxwasher.IsVisible = true;
                        imgxwasher.Source    = xjson[0].foto;
                    }
                }
                else
                {
                    btnCancel.IsVisible = true;

                    await DisplayAlert("Pudo haber un error", "Intenta otra ves mas tarde, recuerda que siempre puedes cancelar tus servicios.", "ok");
                }
            }
            else
            {
                await Navigation.PopModalAsync();
            }

            CatorMain.IsVisible = false;
            CatorMain.IsRunning = false;
        }