//Update user data private async void Update() { try { if (!string.IsNullOrEmpty(Password)) { var isupdate = await FirebaseHelper.UpdateUser(Email, Password); if (isupdate) { await App.Current.MainPage.DisplayAlert("Update Success", "", "Ok"); } else { await App.Current.MainPage.DisplayAlert("Error", "Record not update", "Ok"); } } else { await App.Current.MainPage.DisplayAlert("Password Require", "Please Enter your password", "Ok"); } } catch (Exception e) { Debug.WriteLine($"Error:{e}"); } }
private async void SignUp() { //null or empty field validation, check weather email and password is null or empty Freelancer model = new Freelancer(); ExpHistory EmptyExp = new ExpHistory(); model.ContactInfo = new Contact(); model.Location = new LocationInfo(); model.Experience = new List <ExpHistory>(); EmptyExp.ClientName = " "; EmptyExp.ClientContact = " "; model.Firstname = Firstname; model.Middlename = Middlename; model.Lastname = Lastname; model.DailyRate = Convert.ToInt32(DailyRate); model.ContactInfo.CellphoneNo = CellphoneNo; model.ContactInfo.LandlineNo = " "; model.Location.Barangay = Barangay; model.Location.City = City; model.Location.Region = Region; model.DailyRate = Convert.ToInt32(DailyRate); model.Experience.Add(EmptyExp); model.Email = Email; model.Password = SHA512StringHash(Password); model.IsFreelancer = UserType == "Worker" ? true : false; 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(model); //var imagepath = await FirebaseHelper.GetFile(email + ".png"); var imagepath = "default_pic.png"; if (user) { await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok"); await App.Current.MainPage.Navigation.PushAsync(new MainMasterDetailPage(Email, imagepath, string.Format("{0} {1}", model.Firstname, model.Lastname))); } else { await App.Current.MainPage.DisplayAlert("Error", "SignUp Fail", "OK"); } } }
//Delete user data private async void Delete() { try { var isdelete = await FirebaseHelper.DeleteUser(Email); if (isdelete) { await App.Current.MainPage.Navigation.PopAsync(); } else { await App.Current.MainPage.DisplayAlert("Error", "Record not delete", "Ok"); } } catch (Exception e) { Debug.WriteLine($"Error:{e}"); } }
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); var imagepath = await FirebaseHelper.GetFile(email + ".png"); //firebase return null valuse if user data not found in database if (user != null) { if (Email == user.Email && SHA512StringHash(Password) == user.Password) { await App.Current.MainPage.DisplayAlert("Login Success", "", "Ok"); //Navigate to Wellcom page after successfuly login //pass user email to welcom page await App.Current.MainPage.Navigation.PushAsync(new MainMasterDetailPage(Email, imagepath, string.Format("{0} {1}", user.Firstname, user.Lastname))); } 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"); } } }