private async void Register() { // Validate the field of form var response = MethodsHelper.IsValidField( "S", 3, 20, "firts name", this.FirtsName, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "S", 3, 20, "last name", this.LastName, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "S", 0, 0, "email", this.Email, false, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } var isValidEmail = MethodsHelper.IsValidEmail(this.Email); if (!isValidEmail) { await dialogService.ShowMessage( "Error", "You must enter an valid email", "Accept"); return; } response = MethodsHelper.IsValidField( "S", 6, 10, "password", this.Password, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "S", 6, 10, "password confirm", this.Confirm, true, true, this.Password); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Set status controls SetStatusControl(false, true, true, 1); response = await apiService.CheckConnection(); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Use the user registration API var user = new User { AppName = MethodsHelper.GetAppName(), Email = this.Email, FirstName = this.FirtsName, LastName = this.LastName, Password = this.Password, UserTypeId = Convert.ToInt32("5"), }; response = await apiService.Post( MethodsHelper.GetUrlAPI(), "/api", "/Users", user); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Set status controls SetStatusControl(true, true, false, 0); // Set Initialize the fields SetInitializaFields(); // Go back login await dialogService.ShowMessage( "Information", string.Format( "{0}{1}", "User registered successfully, you can now log in to the ", "application whit this username and password...!!!"), "Accept"); await navigationService.GoBackOnLogin(); }
private async void Save() { if (this.mainViewModel.UserData.UserTypeId != 2) { // Validate the field of form var response = MethodsHelper.IsValidField( "S", 3, 20, "firts name", this.FirstName, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "S", 3, 20, "last name", this.LastName, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Get image byte[] imageArray = null; if (file != null) { imageArray = FilesHelper.ReadFully(file.GetStream()); // file.Dispose(); } // Set status controls SetStatusControl(false, false, true, 1); response = await apiService.CheckConnection(); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Use the user registration API var userEdit = new UserEdit { AppName = MethodsHelper.GetAppName(), Email = this.Email, FirstName = this.FirstName, ImageArray = imageArray, ImagePath = this.mainViewModel.UserData.ImagePath, LastName = this.LastName, Password = this.mainViewModel.UserData.Password, Telephone = this.Telephone, UserId = this.mainViewModel.UserData.UserId, UserTypeId = 5, }; response = await apiService.Put <UserEdit>( MethodsHelper.GetUrlAPI(), "/api", "/Users", this.mainViewModel.Token.TokenType, this.mainViewModel.Token.AccessToken, userEdit); if (!response.IsSuccess) { // Set status controls this.SetStatusControl(true, true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Update data Image this.mainViewModel.UserData.FirstName = this.FirstName; this.mainViewModel.UserData.LastName = this.LastName; this.mainViewModel.UserData.Telephone = this.Telephone; this.mainViewModel.UserData.ImagePath = userEdit.ImagePath; // Set status controls this.SetStatusControl(true, true, false, 0); // Go back login await dialogService.ShowMessage( "Information", "Infromation updated successfully...!!!", "Accept"); } }
private async void Save() { // Validate the field of form #region Current Email var response = MethodsHelper.IsValidField( "S", 0, 0, "email", this.CurrentEmail, false, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } var isValidEmail = MethodsHelper.IsValidEmail(this.CurrentEmail); if (!isValidEmail) { await dialogService.ShowMessage( "Error", "You must enter an valid current email", "Accept"); return; } #endregion Current Email // Verify if it is valid the email current if (!this.CurrentEmail.Equals(this.mainViewModel.UserData.Email)) { await dialogService.ShowMessage( "Error", "This email not are registered in the sistem...!!!", "Accept"); return; } #region New Email response = MethodsHelper.IsValidField( "S", 0, 0, "new email", this.NewEmail, false, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } isValidEmail = MethodsHelper.IsValidEmail(this.NewEmail); if (!isValidEmail) { await dialogService.ShowMessage( "Error", "You must enter an valid new email", "Accept"); return; } #endregion New Email #region Confirm Email response = MethodsHelper.IsValidField( "S", 0, 0, "confirm email", this.ConfirmEmail, false, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } isValidEmail = MethodsHelper.IsValidEmail(this.ConfirmEmail); if (!isValidEmail) { await dialogService.ShowMessage( "Error", "You must enter an valid confirm email", "Accept"); return; } #endregion Confirm Email #region Email Confirm and new Email response = MethodsHelper.IsValidField( "S", 0, 0, "email confirm", this.ConfirmEmail, false, true, this.NewEmail); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } #endregion Email Confirm and new Email // Validate that the emails are different if (this.CurrentEmail.Equals(this.NewEmail)) { await dialogService.ShowMessage( "Error", "The new email can not be the same as the current email .. !!!", "Accept"); return; } // Set status controls SetStatusControl(false, true, "Green", 1); response = await apiService.CheckConnection(); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, false, "Green", 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Use the user registration API var userEdit = new UserEdit { AppName = MethodsHelper.GetAppName(), Email = this.mainViewModel.UserData.Email, FirstName = this.mainViewModel.UserData.FirstName, LastName = this.mainViewModel.UserData.LastName, NewEmail = this.newEmail, Password = this.mainViewModel.UserData.Password, UserId = this.mainViewModel.UserData.UserId, UserTypeId = 5, }; response = await apiService.Put <UserEdit>( MethodsHelper.GetUrlAPI(), "/api", "/Users/PutUserEdit", "id", this.mainViewModel.Token.TokenType, this.mainViewModel.Token.AccessToken, userEdit); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, false, "Green", 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Set status controls SetStatusControl(true, false, "Green", 0); // Set Initialize the fields LoadValuesControls(0); // Go back login await dialogService.ShowMessage( "Information", "Successfully modified email, you must log in again...!!! ", "Accept"); // Navigate to LoginPage navigationService.SetMainPage("LoginPage"); }
private async void Save() { // Validate the field of form #region Current Password var response = MethodsHelper.IsValidField( "S", 0, 0, "current password", this.CurrentPassword, false, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } #endregion Current Password #region New Password response = MethodsHelper.IsValidField( "S", 6, 10, "new password", this.NewPassword, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } #endregion New Password #region Confirm Password response = MethodsHelper.IsValidField( "S", 6, 10, "password confirm", this.ConfirmPassword, true, true, this.NewPassword); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } #endregion Confirm Password // Set status controls SetStatusControl(false, true, "Green", 1); response = await apiService.CheckConnection(); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, false, "Green", 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Use the user registration API var userEdit = new UserEdit { AppName = MethodsHelper.GetAppName(), Email = this.mainViewModel.UserData.Email, FirstName = this.mainViewModel.UserData.FirstName, LastName = this.mainViewModel.UserData.LastName, NewEmail = this.mainViewModel.UserData.Email, Password = this.CurrentPassword, NewPassword = this.NewPassword, UserId = this.mainViewModel.UserData.UserId, UserTypeId = 5, }; response = await apiService.EditPassword( MethodsHelper.GetUrlAPI(), "/api", "/Users/EditPassword", this.mainViewModel.Token.TokenType, this.mainViewModel.Token.AccessToken, userEdit); if (!response.IsSuccess) { // Set status controls SetStatusControl(true, false, "Green", 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Set status controls SetStatusControl(true, false, "Green", 0); // Set Initialize the fields LoadValuesControls(0); // Go back login await dialogService.ShowMessage( "Information", "Successfully modified password, you must log in again...!!! ", "Accept"); // Navigate to LoginPage navigationService.SetMainPage("LoginPage"); }