Example #1
0
        public static async Task <bool> RegisterUser(string email, string password)
        {
            try
            {
                return(await auth.RegisterUser(email, password));
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");

                return(false);
            }
        }
Example #2
0
        private async void Btn_registration_clicked(object sender, EventArgs e)
        {
            //tutti i campi inseriti
            if (Entry_name.Text == null || Entry_email.Text == null || Entry_Password.Text == null || Entry_surname.Text == null)
            {
                await DisplayAlert("Errore", "Inserisci tutti i campi", "OK");

                return;
            }

            //email formato giusto
            bool email = IsValidEmail(Entry_email.Text);

            if (!email)
            {
                await DisplayAlert("Errore", "Inserisci un indirizzo email valido", "OK");

                return;
            }

            //autentico
            bool created = await auth.RegisterUser(Entry_email.Text, Entry_Password.Text);

            if (created)
            {
                Utente user = new Utente(Entry_name.Text, Entry_surname.Text, Entry_email.Text, Entry_Password.Text);
                await CrossCloudFirestore.Current
                .Instance
                .GetCollection("utenti")
                .GetDocument(Entry_email.Text)
                .GetCollection("Info")
                .CreateDocument()
                .SetDataAsync(user);

                await Navigation.PushAsync(new ListPage());

                Navigation.RemovePage(this);

                await DisplayAlert("Benvenuti!", "Cliccare sul pulsante \"+\" per aggiungere una prenotazione. \n  " +
                                   "Tenerla premuta per poterla eliminare.", "OK");
            }
            else
            {
                await DisplayAlert("Sign Up Failed", "Something went wrong. Try again!", "OK");
            }
        }