private async void Login() { //null or empty field validation, check weather email and password is null or empty if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { await App.Current.MainPage.DisplayAlert("Empty Values", "Please enter Email and Password", "OK"); } else { //call GetUser function which we define in Firebase helper class var user = await FirebaseHelper.GetUser(Email); //firebase return null valuse if user data not found in database if (user != null) { if (Email == user.Email && Password == user.Password) { //await App.Current.MainPage.DisplayAlert("Login Success", "", "Ok"); //Navigate to Wellcom page after successfuly login //pass user email to welcom page try { var user1 = await App.Database.GetItemUser(Email); if (user1 == null) { App.Database.SaveItemUser(user); } // await App.Current.MainPage.Navigation.PushAsync(new ChangesCategoryPage(Email, Password)); var main = await TasksAndMenu.Create(user.Email); await App.Current.MainPage.Navigation.PushModalAsync(main); } catch (Exception e) { await App.Current.MainPage.DisplayAlert("Login Fail", e.StackTrace.ToString(), "OK"); } } else { await App.Current.MainPage.DisplayAlert("Login Fail", "Please enter correct Email and Password", "OK"); } } else { await App.Current.MainPage.DisplayAlert("Login Fail", "User not found", "OK"); } } }
private async void SignUp() { //call GetUser function which we define in Firebase helper class var user1 = await FirebaseHelper.GetUser(Email); //firebase return null valuse if user data not found in database if (user1 != null) { await App.Current.MainPage.DisplayAlert("Login Fail", "Such user already exists", "OK"); } else { //null or empty field validation, check weather email and password is null or empty if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { await App.Current.MainPage.DisplayAlert("Empty Values", "Please enter Email and Password", "OK"); } else { //call AddUser function which we define in Firebase helper class var user = await FirebaseHelper.AddUser(Email, Password); //AddUser return true if data insert successfuly if (user) { await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok"); //Navigate to Wellcom page after successfuly SignUp //pass user email to welcom page var main = await TasksAndMenu.Create(Email); await App.Current.MainPage.Navigation.PushModalAsync(main); } else { await App.Current.MainPage.DisplayAlert("Error", "SignUp Fail", "OK"); } } } }
protected override async void OnAppearing() { base.OnAppearing(); await App.Database.CreateTableUsers(); await App.Database.CreateTableCategory(); await App.Database.CreateTableTask(); List <User> user = await App.Database.GetItemsUsers(); if (user.Count != 0) { var main = await TasksAndMenu.Create(user[0].Email); await Navigation.PushModalAsync(main); } }
private async void OnDoneButtonClicked(object sender, EventArgs args) { var name = NameText.Text; if ((name == "") || name == null) { await App.Current.MainPage.DisplayAlert(AppResources.Error, AppResources.ErrorNameEmpty, AppResources.OK); return; } var category = new Category { Name = name, IdUser = userId }; await App.Database.SQLiteDatabase.InsertAsync(category); var mainPage = await TasksAndMenu.Create(userId); App.Current.MainPage = mainPage; }