Beispiel #1
0
        private void btnUpdate_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ent1.Text))
            {
                ent1.Focus();
            }
            else if (string.IsNullOrEmpty(ent2.Text))
            {
                ent2.Focus();
            }
            else
            {
                userDataBase = new UserDataBase();
                var user_exist = userDataBase.GetMembers().ToList();
                var idx        = user_exist[0].id_cliente;

                HttpClient client      = new HttpClient();
                var        uri         = "http://washdryapp.com/app/public/cliente/actualiza";
                var        value_check = new Dictionary <string, string>
                {
                    { "id_usuario", idx.ToString() }
                };
                var content = new FormUrlEncodedContent(value_check);
            }
        }
Beispiel #2
0
        public Solicitar()
        {
            InitializeComponent();
            stepBar.Opacity = 0;
            stepBar.FadeTo(1, 1000, null);
            stepBar.ScaleTo(1, 1000);
            //local: StepProgressBarControl
            frame1.IsVisible = true;
            frame2.IsVisible = false;
            frame3.IsVisible = false;
            frame4.IsVisible = false;
            frame5.IsVisible = false;

            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();

            idx = user_exist[0].id_cliente;
            _   = getdireccion(); _ = getAutos(); _ = CurrentLocation();
            _   = getPaquetes(); _ = getWashers();

            string hour    = DateTime.Now.ToString("HH");
            string minute  = DateTime.Now.ToString("mm");
            string sencond = DateTime.Now.ToString("ss");

            _timePicker.Time = new TimeSpan(Convert.ToInt32(hour), Convert.ToInt32(minute), Convert.ToInt32(sencond));


            FDPPicker.SelectedIndexChanged     += FDPPickerSelectedIndexChanged;
            pickertamanio.SelectedIndexChanged += TamPickerSelected;
        }
Beispiel #3
0
        //[Obsolete]
        public MainPage()
        {
            InitializeComponent();

            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers();
            int RowCount   = 0;
            int usercount  = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);

            if (RowCount > 0)
            {
                var userLite = user_exist.First();
                var id       = userLite.id;
                CallDataTCUser(id);
            }
            else
            {
                Application.Current.MainPage =
                    new Views.SignInPage();
            }


            //listMembers.ItemsSource = members;
        }
Beispiel #4
0
        private void btnCerrarSession_Clicked(object sender, EventArgs e)
        {
            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();
            var idx        = user_exist[0].id;
            var tok        = user_exist[0].token;

            var userW = new User();

            userW.id_cliente = 0;

            userW.name           = "";
            userW.nombre         = "";
            userW.password       = "";
            userW.username       = "";
            userW.remember_token = "";
            userW.google_id      = "";
            userW.email          = "";
            userW.token          = tok;
            userW.status         = 0;
            userDataBase.DeleteMember(idx);
            userDataBase.AddMember(userW);



            Application.Current.MainPage = new NavigationPage(new Login());
        }
Beispiel #5
0
        public Test()
        {
            InitializeComponent();

            userDb = new UserDataBase();
            var users = userDb.GetMembers();
            //userView.ItemsSource = users;
        }
Beispiel #6
0
        public master()
        {
            InitializeComponent();
            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();

            namelbl.Text = user_exist[0].name + user_exist[0].id_cliente;
            InfoUserweb(user_exist[0].id);
        }
Beispiel #7
0
        public LavadorInfo()
        {
            InitializeComponent();
            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();

            idx = user_exist[0].id_cliente;

            _ = getSolicitudStatis();
        }
Beispiel #8
0
        public Agendar()
        {
            InitializeComponent();


            db = new UserDataBase();
            var user_exist = db.GetMembers().ToList();

            idx = user_exist[0].id_cliente;
        }
Beispiel #9
0
        public async Task GetVisitasWeb()
        {
            try
            {
                userDataBase = new UserDataBase();
                var        user_exist  = userDataBase.GetMembers().ToList();
                HttpClient client      = new HttpClient();
                var        uri         = "http://www.washdryapp.com/app/public/direccion/listado/" + user_exist[0].id;
                var        responseMsg = await client.GetAsync(uri);



                switch (responseMsg.StatusCode)
                {
                case System.Net.HttpStatusCode.InternalServerError:
                    Console.WriteLine("----------------------------------------------_____:Here status 500");

                    //xlabel.Text = "error 500";
                    // Cator.IsVisible = false;
                    break;


                case System.Net.HttpStatusCode.OK:
                    Console.WriteLine("----------------------------------------------_____:Here status 200");

                    // ylabel.Text = "Ultimas noticas de proyectos";


                    // var json_ = JsonConvert.DeserializeObject<List<VisitasMod>>(xjson);

                    string xjson = await responseMsg.Content.ReadAsStringAsync();

                    //DireccApiCall

                    HttpContent contentD = responseMsg.Content;
                    var         xjsonD   = await contentD.ReadAsStringAsync();

                    var json_d = JsonConvert.DeserializeObject <List <DireccionesApiCall> >(xjsonD);
                    ListDirecciones.ItemsSource = json_d;

                    break;
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("", "" + ex.ToString(), "ok");

                //  Cator.IsVisible = false;

                //  CatorT.Text = "Ha habido un error";
                return;
            }
        }
Beispiel #10
0
        //Termina diseño


        // BackEnd

        public async void TryAccess_token()
        {
            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers();
            int RowCount   = 0;
            int usercount  = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);

            if (RowCount > 0)
            {
                var userLite   = user_exist.First();
                var tokenCheck = userLite.tok;


                HttpClient client = new HttpClient();



                var value_check = new Dictionary <string, string>
                {
                    { "token", tokenCheck }
                };


                var content  = new FormUrlEncodedContent(value_check);
                var response = await client.PostAsync("https://trustfundapp.herokuapp.com/m/ensureToken", content);

                switch (response.StatusCode)
                {
                case (System.Net.HttpStatusCode.OK):

                    Application.Current.MainPage = new NavigationPage(new MainPage());


                    break;


                case (System.Net.HttpStatusCode.Forbidden):

                    ErrorMsn.IsVisible = true; ErrorMsn.Text = "Porfavor confirma tus datos de sesión";
                    Cator.IsVisible    = false; Cator.IsRunning = false;
                    Username.IsVisible = true; Pass.IsVisible = true;
                    Pass.Focus();

                    SubmitButton.Text = "Volver a Intentar";

                    break;
                }
            }
        }
Beispiel #11
0
        public SignUp()
        {
            InitializeComponent();
            Title = "WASH DRY";
            //PropertyMaximumDate = DateTime.Now;
            userdb = new UserDataBase();
            var user_token = userdb.GetMembers().ToList();

            int RowCount = 0;
            int regcount = user_token.Count();

            RowCount = Convert.ToInt32(regcount);
            var token = user_token[0].token;
        }
Beispiel #12
0
        protected override void OnAppearing()
        {
            Cator.IsVisible = true;

            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();

            if (user_exist.Count() > 0)
            {
                _ = GetInfoUser();
            }
            else
            {
                lbl1.Text       = "Error. No hay info de usuario en SQLite";
                Cator.IsVisible = false;
            }
        }
Beispiel #13
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await splashImage.FadeTo(1, 150, null);

            await splashImage.ScaleTo(1, 1000); //Time-consuming processes such as initialization

            await splashImage.ScaleTo(0.6, 1500, Easing.BounceOut);

            await splashImage.FadeTo(0, 270, null);

            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();
            int RowCount   = 0;
            int usercount  = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);

            if (RowCount == 1)
            {
                var ux = user_exist[0].id_cliente;
                if (ux != 0)
                {
                    Application.Current.MainPage = new MainPage();
                }
                else
                {
                    Application.Current.MainPage = new NavigationPage(new Banner());
                }
            }
            else
            {
                Application.Current.MainPage = new NavigationPage(new Banner());
            }
        }
Beispiel #14
0
        public async Task GetInfoUser()
        {
            try
            {
                userDataBase = new UserDataBase();
                var        user_exist = userDataBase.GetMembers().ToList();
                var        idx        = user_exist[0].id_cliente;
                HttpClient client     = new HttpClient();
                var        uri        = "http://washdryapp.com/app/public/cliente/getPerfil/" + idx; //+ user_exist[0].id;



                var responseMsg = await client.GetAsync(uri);



                switch (responseMsg.StatusCode)
                {
                case System.Net.HttpStatusCode.InternalServerError:
                    Console.WriteLine("----------------------------------------------_____:Here status 500");

                    //xlabel.Text = "error 500";
                    // Cator.IsVisible = false;
                    break;


                case System.Net.HttpStatusCode.OK:
                    Console.WriteLine("----------------------------------------------_____:Here status 200");



                    HttpContent contentD = responseMsg.Content;
                    var         xjsonD   = await contentD.ReadAsStringAsync();



                    var json_d = JsonConvert.DeserializeObject <List <User> >(xjsonD);


                    ImgProfile.Source = json_d[0].foto;     //email
                    fname.Text        = json_d[0].nombre;

                    lbl1.Text = json_d[0].name;
                    lbl2.Text = json_d[0].email;
                    lbl3.Text = json_d[0].fecha_nac;



                    break;
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("", "" + ex.ToString(), "ok");

                //  Cator.IsVisible = false;

                //  CatorT.Text = "Ha habido un error";
                return;
            }
            Cator.IsVisible = false;
        }
Beispiel #15
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;
        }
Beispiel #16
0
        private async void Registrar_Clicked(object sender, EventArgs e)
        {
            Cator.IsVisible        = true;
            btnRegistrar.IsVisible = false;
            userdb = new UserDataBase();
            var reg_existL = userdb.GetMembers().ToList();
            // var idRegL = reg_existL[0].id;
            var nombreL   = Nombre.Text;
            var appL      = Appaterno.Text;
            var apmL      = Apmaterno.Text;
            var fca_nacL  = Fca_nac.Date.ToString("yyyy-MM-dd");   //Fca_nac.Date.ToString();
            var telefonoL = Telefono.Text;
            var correoL   = Correo.Text;
            var passwordL = Password.Text;

            // var foto = imgx.Source;
            //userdb.UpdateAll(idRegL, nombreL, appL, apmL, fca_nacL.ToString(), telefonoL, correoL, passwordL, 1);
            try
            {
                var reg_exist = userdb.GetMembers().ToList();
                var nombre    = nombreL;// reg_exist[0].nombre;
                var app       = appL;
                var apm       = apmL;
                var fca_nac   = fca_nacL;
                var telefono  = telefonoL;
                var correo    = correoL;
                var password  = passwordL;
                var confPass  = passwordL;
                var tokens    = reg_exist[0].token;
                if (tokens == null || tokens == "")
                {
                    userdb = new UserDataBase();
                    var user_token   = userdb.GetMembers().ToList();
                    var tokenUsuario = user_token[0].token;
                    tokens = tokenUsuario;
                }
                if (password == "" || password == null)
                {
                    password = Password.Text;
                    confPass = ConfirmaPass.Text;
                }
                if (password == confPass)
                {
                    //GUARDAR IMAGEN
                    var content1 = new MultipartFormDataContent();
                    content1.Add(new StreamContent(_image.GetStream()), "\"file\"", $"\"{_image.Path}\"");

                    var httpClient1 = new System.Net.Http.HttpClient();
                    httpClient1.BaseAddress = new Uri("http://www.washdryapp.com");
                    var url1         = "http://www.washdryapp.com/oficial/ImagenesPerfil.php";
                    var responseMsg1 = await httpClient1.PostAsync(url1, content1);

                    var remotePath = await responseMsg1.Content.ReadAsStringAsync();

                    imagen_name = remotePath;
                    //*************
                    var httpClient = new HttpClient();
                    //var url = /washer/guardar;
                    var url = "http://www.washdryapp.com/app/public/cliente/registra";

                    var value_check = new Dictionary <string, string>
                    {
                        { "nombre", nombre },
                        { "app", app },
                        { "apm", apm },

                        { "fecha_nac", fca_nac },
                        { "telefono", telefono },
                        { "email", correo },
                        { "password", password },
                        { "token", tokens },
                        { "foto", imagen_name }
                    };
                    var content     = new FormUrlEncodedContent(value_check);
                    var responseMsg = await httpClient.PostAsync(url, content);

                    switch (responseMsg.StatusCode)
                    {
                    case System.Net.HttpStatusCode.InternalServerError:
                        await DisplayAlert("error", "error status 500 InternalServerError", "ok");

                        break;

                    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:
                        string xjson = await responseMsg.Content.ReadAsStringAsync();

                        //var json_ = JsonConvert.DeserializeObject<List<User>>(xjson);

                        //userdb.UpdateMember();

                        await Navigation.PopAsync();
                        await DisplayAlert("Success", "Se agrego Correctamente ", "ok");

                        break;

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

                        break;
                    }
                }
                else
                {
                    await DisplayAlert("error", "Contraseña no coinciden", "ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", "Error : " + ex.ToString(), "OK");
            }


            Cator.IsVisible        = false;
            btnRegistrar.IsVisible = true;

            //Application.Current.MainPage = new NavigationPage(new Login());
        }
Beispiel #17
0
        private async void btnAddDirecc_Clicked(object sender, EventArgs e)
        {
            var descx = desc.Text;

            var gpx = gp.Text;

            if (String.IsNullOrEmpty(gp.Text))
            {
                gpx = "Referencia no encontrada";
            }

            if (string.IsNullOrEmpty(descx))
            {
                await DisplayAlert("Descripcion", "Ingrese una descripcion", "ok");

                desc.Focus();
            }

            else if (string.IsNullOrEmpty(Latitud.Text))
            {
                await DisplayAlert("Error", "Ha habido un error con el GPS verifique que este cuente con este servicio activado", "ok");
            }

            else if (string.IsNullOrEmpty(Longitud.Text))
            {
                await DisplayAlert("Error", "Ha habido un error con el GPS verifique que este cuente con este servicio activado", "ok");
            }
            else
            {
                try
                {
                    userDataBase = new UserDataBase();
                    var user_exist = userDataBase.GetMembers().ToList();



                    var httpClient = new System.Net.Http.HttpClient();

                    var value_check = new Dictionary <string, string>
                    {
                        { "descripcion", descx },
                        { "id_usuario", user_exist[0].id_cliente.ToString() },
                        { "direccion", gpx },
                        //  {"direccion", descx },
                        { "latitude", Latitud.Text },
                        { "longitude", Longitud.Text },
                    };
                    var content = new FormUrlEncodedContent(value_check); //solicitud/agrega

                    HttpClient client = new HttpClient();


                    //  IsSuccessStatusCode = false


                    var responseMsg = await httpClient.PostAsync("http://www.washdryapp.com/app/public/direccion/guardar", content);

                    // ... subir a internet


                    if (responseMsg.IsSuccessStatusCode)
                    {
                        string xjson = await responseMsg.Content.ReadAsStringAsync();
                        await DisplayAlert("Exito", "Direccion agregada correctamente. ", "ok");

                        GetVisitasWeb();
                        //await DisplayAlert("error", "error status 419 Probelmas con respuesta del server, intente mas tarde o reinicie la aplicacion", "ok");
                    }
                    else
                    {
                        string xjson = await responseMsg.Content.ReadAsStringAsync();

                        switch (responseMsg.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("200", "error status 404  ", "ok");

                            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)
                {
                    await DisplayAlert("error", "Error : " + ex.ToString(), "ok");
                }
            }
        }
Beispiel #18
0
        private async void btnRegistDone_Clicked(object sender, EventArgs e)
        {
            Cator.IsRunning         = true;
            Cator.IsVisible         = true;
            btnRegistDone.IsEnabled = false;
            var user = User_.Text;
            var pass = Pass_.Text;

            if (string.IsNullOrEmpty(User_.Text) || string.IsNullOrWhiteSpace(User_.Text))
            {
                User_.Focus();
            }
            else if (string.IsNullOrEmpty(Pass_.Text) || string.IsNullOrWhiteSpace(Pass_.Text))
            {
                Pass_.Focus();
            }

            else
            {
                HttpClient client = new HttpClient();

                UserDb = new UserDataBase();
                var userW       = new User();
                var user_exista = UserDb.GetMembers().ToList();
                var token       = user_exista[0].token;


                var value_check = new Dictionary <string, string>
                {
                    { "email", user },
                    { "pass", pass },
                    { "token", token }
                };

                var contentx = new FormUrlEncodedContent(value_check);

                try
                {
                    var response = await client.PostAsync("http://www.washdryapp.com/app/public/solicitud/login_cliente", contentx);


                    HttpContent content = response.Content;

                    var json = await content.ReadAsStringAsync();

                    if (json == "[{\"nombre\":\"fail\"}]")
                    {
                        await DisplayAlert("Error", "su nombre o contraseña son invalidos", "ok");
                    }
                    else
                    {
                        var json_ = JsonConvert.DeserializeObject <List <User> >(json);



                        var user_x = new User();
                        //var userDataBase = new UserDataBase();
                        UserDb = new UserDataBase();
                        var tk = UserDb.GetMembers().ToList().FirstOrDefault();

                        user_x.email          = json_[0].email;
                        user_x.google_id      = json_[0].google_id;
                        user_x.name           = json_[0].name;
                        user_x.nombre         = json_[0].nombre;
                        user_x.password       = "";
                        user_x.status         = 0;
                        user_x.remember_token = "";
                        user_x.id             = json_[0].id;
                        user_x.id_cliente     = json_[0].id;
                        user_x.username       = json_[0].username;
                        user_x.remember_token = "";//username id
                        user_x.token          = tk.token;


                        UserDb.AddMember(user_x);
                        UserDb.DeleteMember(0);


                        Application.Current.MainPage = new MainPage();
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("", "" + ex.ToString(), "");
                }
            }


            Cator.IsRunning         = false;
            Cator.IsVisible         = false;
            btnRegistDone.IsEnabled = true;
        }
Beispiel #19
0
        private async Task GetSolicitudesfromWeb()
        {
            try
            {
                userDataBase = new UserDataBase();
                HttpClient client = new HttpClient();
                var        id     = userDataBase.GetMembers().ToList();

                var getsol = await client.GetAsync("http://www.washdryapp.com/app/public/solicitud/listado/" + id[0].id_cliente);

                if (getsol.IsSuccessStatusCode)
                {
                    HttpContent respx = getsol.Content;
                    var         res   = await respx.ReadAsStringAsync();

                    var respjson_sol = JsonConvert.DeserializeObject <List <Solicitudes> >(res);

                    if (respjson_sol.Count > 0)
                    {
                        foreach (var item in respjson_sol)
                        {
                            var exist = userDataBase.GetSolicitud(Int32.Parse(item.id_solicitud));
                            if (exist.Count() > 0)
                            {
                            }
                            else
                            {
                                Solicitudes solicitudx = new Solicitudes();
                                solicitudx = item;
                                solicitudx.calificacion = "0";
                                solicitudx.ann          = "";
                                solicitudx.id_washer    = "";
                                solicitudx.id_usuario   = "";
                                solicitudx.cambio       = "";
                                solicitudx.forma_pago   = "";
                                solicitudx.foto_washer  = "";
                                solicitudx.comentario   = "";
                                solicitudx.modelo       = "";
                                solicitudx.placas       = "";
                                solicitudx.paquete      = "";
                                solicitudx.usuario      = "";

                                solicitudx.precio = "";

                                userDataBase.AddSolicitudes(solicitudx);
                            }
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Error", "Error con las solicitudess, intenten en otro momento. Verifique sus datos o wifi", "ok");
                }

                userDataBase = new UserDataBase();
                var solicitudes = userDataBase.GetSolicitudes().ToList();

                if (solicitudes.Count() > 0)
                {
                    ListSolicitudes.ItemsSource = solicitudes;
                    ListSolicitudes.IsVisible   = true;
                    lblestados.IsVisible        = true;
                }
                else
                {
                    lblestados.IsVisible = false;

                    ListSolicitudes.IsVisible = false;
                }
            }
            catch (Exception es)
            {
                await DisplayAlert("", es.ToString(), "ok");
            }
        }
Beispiel #20
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            BuyUnitsIndiCator.IsVisible = true;
            BuyUnitsIndiCator.IsRunning = true;
            Console.WriteLine("----------------------------------------------_____:HELP");
            var id_client = "";



            var uri = "https://trustfundapp.herokuapp.com/tc-list";

            var request = new HttpRequestMessage();

            request.RequestUri = new Uri(uri);

            request.Method = HttpMethod.Get;

            var client = new HttpClient();

            // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(tok_ty, acc_tok);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.SendAsync(request);



            switch (response.StatusCode)
            {
            case System.Net.HttpStatusCode.InternalServerError:
                Console.WriteLine("----------------------------------------------_____:Here status 500");

                LabelMsn.Text = "error 500";
                BuyUnitsIndiCator.IsVisible = false;
                break;


            case System.Net.HttpStatusCode.OK:
                Console.WriteLine("----------------------------------------------_____:Here status 200");

                LabelMsn.Text = "Unidades Disponibles";
                HttpContent content = response.Content;
                string      xjson   = await content.ReadAsStringAsync();



                var json = JsonConvert.DeserializeObject <List <UnitTC> >(xjson);
                // xlabel.Text = myobject.ToString();


                try
                {
                    ListTc.ItemsSource = json;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("", "" + ex.ToString(), "ok");

                    return;
                }


                BuyUnitsIndiCator.IsVisible = false;



                break;
            }


            //call user data



            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers();
            int RowCount   = 0;
            int usercount  = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);

            if (RowCount > 0)
            {
                var userLite = user_exist.First();
                var id       = userLite.id;



                var response_user = await client.GetAsync
                                        ("https://trustfundapp.herokuapp.com/get-user/" + id);

                switch (response.StatusCode)
                {
                case (System.Net.HttpStatusCode.OK):


                    string xjson = await response_user.Content.ReadAsStringAsync();

                    var json_user = JsonConvert.DeserializeObject <User_Info>(xjson);

                    id_client = json_user.id_client;
                    break;

                default:
                    LabelMsn.Text = "Hudo algun error con los datos de usuario";
                    break;
                }
            }
            else
            {
                Application.Current.MainPage = new Views.SignInPage();
            }

            //call user units


            var uriUnits        = "https://trustfundapp.herokuapp.com/tc-info-client/" + id_client;
            var respStatusUnits = await client.GetAsync(uriUnits);

            string xjson_unitsStatus = await respStatusUnits.Content.ReadAsStringAsync();

            var json_ = JsonConvert.DeserializeObject <List <Tc_info_client> >(xjson_unitsStatus);

            var UnitsStatus = json_.First();

            StatusUnits.Text = "Stats: " + UnitsStatus.descrip;
            TotalUnits.Text  = "Unidades Disponibles:" + UnitsStatus.total_units;
            TotalAmount.Text = "Credito:" + UnitsStatus.total;


            //tc_info_client
        }
Beispiel #21
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
            Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.SetFlags(new[] { "CollectionView_Experimental", "Shell_Experimental" });
            Xamarin.FormsMaps.Init(this, savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            LoadApplication(new App());

            //CreateNotificationChannel();

            IsPlayServicesAvailable();
            Log.Debug(TAG, "InstanceID token: " + FirebaseInstanceId.Instance.Token);
            var token = FirebaseInstanceId.Instance.Token;

            //CONSULTAR BD
            userdb = new UserDataBase();
            var userW       = new User();
            var user_exista = userdb.GetMembers().ToList();
            var user_exist  = userdb.GetMembers();
            int RowCount    = 0;
            int usercount   = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);
            if (RowCount > 1)
            {
                userdb.DeleteMembers();
                userW.token  = token;
                userW.status = 0;
                userdb.AddMember(userW);
            }
            else if (RowCount == 1)
            {
                userdb.UpdateMemberToken(user_exista[0].id, token);

                /*if (token != user_exista[0].token)
                 * {
                 *
                 * }*/
            }
            else
            {
                if (token == null || token == "")
                {
                    FinishAffinity();
                }
                userW.id_cliente = 0;

                userW.name           = "";
                userW.nombre         = "";
                userW.password       = "";
                userW.username       = "";
                userW.remember_token = "";
                userW.google_id      = "";
                userW.email          = "";
                userW.token          = token;
                userW.status         = 0;
                userdb.AddMember(userW);
            }
        }