Пример #1
0
        private async void MenuItem_Clicked(object sender, EventArgs e)
        {
            var mItem = sender as MenuItem;
            var info  = (Prenotazione)mItem.CommandParameter;

            await CrossCloudFirestore.Current
            .Instance
            .GetCollection("utenti")
            .GetDocument(auth.GetEmail())
            .GetCollection("Prenotazioni")
            .GetDocument(info.negozio + info.data)
            .DeleteDocumentAsync();

            await CrossCloudFirestore.Current
            .Instance
            .GetCollection("Supermercati")
            .GetDocument(info.negozio)
            .GetCollection("Prenotazioni")
            .GetDocument(auth.GetEmail() + info.data)
            .DeleteDocumentAsync();

            await Navigation.PushAsync(new ListPage()); //così la pagina si aggiorna

            Navigation.RemovePage(this);
        }
Пример #2
0
        private async void Btn_Check_Clicked(object sender, EventArgs e)
        {
            var email = auth.GetEmail();

            int[] count = { 0 };
            dt = new DateTime(year, month, day, ihour, iminute, 0, 0);
            ts = MillisecondsTimestamp(dt);

            var doc = await CrossCloudFirestore.Current
                      .Instance
                      .GetCollection("utenti")
                      .GetDocument(email)
                      .GetCollection("Prenotazioni")
                      .GetDocument(market + date)
                      .GetDocumentAsync();

            if (doc.Exists)
            {
                await DisplayAlert("Errore", "Hai già effettuato una prenotazione per questa data in questo supermercato." +
                                   "\n Lascia spazio per tutti", "OK");

                Btn_Prenota.IsEnabled = false;
                return;
            }

            var group = await CrossCloudFirestore.Current
                        .Instance
                        .GetCollection("Supermercati")
                        .GetDocument(market)
                        .GetCollection("Prenotazioni")
                        .WhereEqualsTo("ts", ts)
                        .GetDocumentsAsync();

            for (int i = 0; i < group.Count; i++)
            {                  //per ogni documento della lista incremento contatore di uno
                count[0] += 1; //se trovo aumento di 1
            }

            if (count[0] <= 5)
            {
                lblCheck.TextColor = Color.Green;
                lblCheck.Text      = $"Libero: {count[0]} persone.";
            }
            else if (count[0] <= 10)
            {
                lblCheck.TextColor = Color.Yellow;
                lblCheck.Text      = $"Leggermente affollato: {count[0]} persone.";
            }
            else
            {
                lblCheck.TextColor = Color.Red;
                lblCheck.Text      = $"Molto affollato: {count[0]} persone.";
            }

            Btn_Prenota.IsEnabled = true;
        }
Пример #3
0
        public PageProfile()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            auth = DependencyService.Get <INterfaceAuth>();

            setUserName(auth.GetEmail());
        }
Пример #4
0
        public MainPage()
        {
            InitializeComponent();
            auth = DependencyService.Get <INterfaceAuth>();

            bool firstrun = auth.GetSharedPreferences();

            if (firstrun)
            {
                Btn_signin_Clicked(auth.GetEmail(), auth.GetPass());
            }
        }
Пример #5
0
        public MainPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            auth = DependencyService.Get <INterfaceAuth>();

            bool firstrun = auth.GetSharedPreferences();

            if (firstrun)
            {
                Btn_signin_Clicked(auth.GetEmail(), auth.GetPass());
            }
        }
Пример #6
0
        private async void Btn_Reserve_Clicked(object sender, EventArgs e)
        {
            var email = auth.GetEmail();

            if (check(oraAnd, oraRit, date, counter))
            {
                var query = await CrossCloudFirestore.Current
                            .Instance
                            .GetCollection("prenotazioni")
                            .GetDocumentsAsync();

                var reserves = query.ToObjects <Prenotazione>();
                int count    = 0;
                if (query.Count != 0)
                {
                    foreach (Prenotazione doc in reserves)
                    {
                        if (String.Equals(doc.data, date) && oraAnd == doc.oraAnd &&
                            minAnd == doc.minutiAnd)
                        {
                            count += doc.numAd;
                        }
                    }
                }

                if (counter + count <= 10)
                {
                    Prenotazione pren = new Prenotazione(oraAnd, minAnd, oraRit, minRit, date, counter);
                    await CrossCloudFirestore.Current
                    .Instance
                    .GetCollection("utenti")
                    .GetDocument(email)
                    .GetCollection("prenotazioni")
                    .AddDocumentAsync(pren);

                    await CrossCloudFirestore.Current
                    .Instance
                    .GetCollection("prenotazioni")
                    .AddDocumentAsync(pren);

                    await DisplayAlert("Successo", "Prenotazione effettuata", "OK");

                    //await Navigation.PushAsync(new TabPage());
                    Navigation.RemovePage(this);
                }
                else
                {
                    await DisplayAlert("Full", "Barche piene, seleziona un altra data", "OK");
                }
            }
        }
Пример #7
0
        private async Task <IEnumerable <Prenotazione> > GetUserPostsList() //prende tutte le pren da firebase e le mette in un IEnumerable
        {
            string email = auth.GetEmail();
            var    group = await CrossCloudFirestore.Current
                           .Instance
                           .GetCollection("utenti")
                           .GetDocument(email)
                           .GetCollection("Prenotazioni")
                           .GetDocumentsAsync();

            var yourModels = group.ToObjects <Prenotazione>();

            return(yourModels);
        }