Ejemplo n.º 1
0
        private async Task doUpdateAsync()
        {
            int opt = 2;

            if (tipo == "Administrador")
            {
                opt = 1;
            }
            else if (tipo == "Básico")
            {
                opt = 0;
            }
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                await FirebaseHelper.UpdateUser(Convert.ToInt32(usuario.ID), entryName.Text, entryApellidos.Text, entryDNI.Text, opt, usuario.DNI);
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                Navigation.PopModalAsync();
            }
        }
Ejemplo n.º 2
0
        private async Task queryUser()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                var person = await FirebaseHelper.GetUser(entryDNI.Text, entryPass.Text);

                if (person != null)
                {
                    if (entryDNI.Text == person.DNI)
                    {
                        App.u = person;
                    }
                }
                else
                {
                    var message = "Usuario incorrecto";
                    DependencyService.Get <IMessage>().LongTime(message);
                    entryDNI.Text  = "";
                    entryPass.Text = "";
                }
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                Navigation.PushModalAsync(new MainPage());
            }
        }
Ejemplo n.º 3
0
        private async Task doUpdateAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                decimal price = Convert.ToDecimal(entryPrecio.Text, System.Globalization.CultureInfo.CurrentCulture);
                await FirebaseHelper.UpdateActividad(Convert.ToInt32(act.ID), entryTitulo.Text, entryLugar.Text,
                                                     editorDescripcion.Text,
                                                     entryFoto.Text,
                                                     pickerBus.Title,
                                                     price,
                                                     fechaAct.Date,
                                                     Convert.ToInt32(entryPlazas.Text));
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                Navigation.PopModalAsync();
            }
        }
Ejemplo n.º 4
0
        private async Task loadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                List <User> listUser = await FirebaseHelper.GetAllUsers();

                List <Apuntado> listAp = await FirebaseHelper.GetApuntados();

                List <Actividad> list = await FirebaseHelper.GetActivities();

                var listFilter = from act in list
                                 join ap in listAp
                                 on act.ID equals ap.IDAct
                                 join user in listUser
                                 on ap.IDUser equals user.ID
                                 where (user.DNI == App.u.DNI)
                                 select new { Titulo = act.Titulo, Fecha = act.Fecha, Estado = ap.Estado };;
                lw_Act.ItemsSource = listFilter;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
            }
        }
Ejemplo n.º 5
0
        private async Task LoadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                List <User> listUser = await FirebaseHelper.GetAllUsers();

                List <Apuntado> listAp = await FirebaseHelper.GetApuntados();

                List <Actividad> list = await FirebaseHelper.GetActivities();

                var listFilter = from ac in list
                                 join ap in listAp
                                 on ac.ID equals ap.IDAct
                                 join user in listUser
                                 on ap.IDUser equals user.ID
                                 where (ac.ID == act.ID)
                                 select new { Name = user.Name, Apellido = user.Apellido, Estado = ap.Estado, ID = ap.ID };
                lw_Users.ItemsSource = listFilter;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
            }
        }
Ejemplo n.º 6
0
        private async Task queriesAsync()
        {
            if (App.u == null)
            {
                var message = "No permitido usted no esta registrado";
                DependencyService.Get <IMessage>().LongTime(message);
            }
            else
            {
                var tokenSource2     = new CancellationTokenSource();
                CancellationToken ct = tokenSource2.Token;
                try
                {
                    Actividad   activity = (Actividad)this.BindingContext;
                    List <User> listUser = await FirebaseHelper.GetAllUsers();

                    List <Apuntado> listAp = await FirebaseHelper.GetApuntados();

                    List <Actividad> list = await FirebaseHelper.GetActivities();

                    var listFilter = from act in list
                                     join ap in listAp
                                     on act.ID equals ap.IDAct
                                     join user in listUser
                                     on ap.IDUser equals user.ID
                                     where (user.DNI == App.u.DNI && act.Titulo == activity.Titulo)
                                     select act;
                    if (listFilter.Count() > 0)
                    {
                        var message = "Ya estas apuntado";
                        DependencyService.Get <IMessage>().LongTime(message);
                    }
                    else if (activity.Plazas == 0)
                    {
                        var message = "No quedan mas plazas";
                        DependencyService.Get <IMessage>().LongTime(message);
                    }
                    else
                    {
                        await FirebaseHelper.AddApuntado(activity.ID, App.u.ID);

                        await FirebaseHelper.UpdateActividadPlazas(activity.ID);

                        Navigation.PushModalAsync(new MainPage());
                    }
                }
                catch (OperationCanceledException e)
                {
                    Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
                }
                finally
                {
                    tokenSource2.Dispose();
                }
            }
        }
Ejemplo n.º 7
0
        private async Task doInsertAsync(int opt)
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                await FirebaseHelper.AddUser(entryName.Text, entryApellidos.Text, entryDNI.Text, "12345", opt);
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                Navigation.PopModalAsync();
            }
        }
Ejemplo n.º 8
0
        private async Task doDeleteAsync(int id)
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                await FirebaseHelper.DeleteUser(id);
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                LoadListAsync();
            }
        }
Ejemplo n.º 9
0
        private async Task LoadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                Actividad        act  = (Actividad)this.BindingContext;
                List <Actividad> list = await FirebaseHelper.GetActivities();

                lw_Act.ItemsSource = list;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
            }
        }
Ejemplo n.º 10
0
        private async Task loadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                List <Actividad> list = await FirebaseHelper.GetActivities();

                var listFilter = from act in list
                                 where (act.bus == "No")
                                 select act;
                listView.ItemsSource = listFilter;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
            }
        }
Ejemplo n.º 11
0
        private async Task loadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                List <User> listUser = await FirebaseHelper.GetAllUsers();

                var queryList = from us in listUser
                                where (us.type == 1)
                                select us;
                lw_Contact.ItemsSource = queryList;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
            }
        }
Ejemplo n.º 12
0
        private async Task LoadListAsync()
        {
            var tokenSource2     = new CancellationTokenSource();
            CancellationToken ct = tokenSource2.Token;

            try
            {
                List <User> users = await FirebaseHelper.GetAllUsers();

                var queryUser = from u in users
                                where (u.DNI != App.u.DNI && u.type != 1)
                                select u;
                lw_AdminUser.ItemsSource = queryUser;
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
            finally
            {
                tokenSource2.Dispose();
                LoadListAsync();
            }
        }