private async void Save() { // Validate the fields of the form if (this.NationalityId == 0) { await this.dialogService.ShowMessage( "Error", "You must select an nationality...!!!", "Accept"); return; } var response = MethodsHelper.IsValidField( "I", 8, 8, "identification card", this.IdentificationCard, true, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Define the status of the controls this.SetStatusControl(false, true, 1); // Check the connection internet response = await this.apiService.CheckConnection(); if (!response.IsSuccess) { // Define the status of the controls this.SetStatusControl(true, false, 0); await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Create the object var cneIvssData = new CneIvssDataItem { // BirthDate = this.BirthDate, BirthDate = DateTime.Today.Date, IdentificationCard = this.IdentificationCard, IsCne = true, IsIvss = false, NationalityId = this.NationalityId, UserId = this.mainViewModel.UserData.UserId, }; response = await this.apiService.Post <CneIvssDataItem>( MethodsHelper.GetUrlAPI(), "/api", "/CneIvssDatas/PostCneIvssDataInsertByOption/?_option=cne", mainViewModel.Token.TokenType, mainViewModel.Token.AccessToken, cneIvssData); if (!response.IsSuccess) { // Define the status of the controls this.SetStatusControl(true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Add record to CneData this.cantvViewModel.UpdateCneData( 1, this.ToCneItemViewModel((CneIvssDataItem)response.Result)); // Navigate to back await this.navigationService.GoBackOnMaster(); // Define the status of the controls this.SetStatusControl(true, false, 0); }
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() { var response = MethodsHelper.IsValidField( "I", 8, 20, "number tracking", this.Tracking, true, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "I", 8, 20, "number tracking", this.Tracking, true, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Define control format this.SetStatusControl(false, true, 1); response = await apiservices.CheckConnection(); if (!response.IsSuccess) { // Define control format this.SetStatusControl(true, false, 0); await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } var zoomDataItem = new ZoomDataItem { Tracking = this.Tracking, UserId = mainViewModel.UserData.UserId, ZoomDataId = 0, }; // Save the data CatvData response = await apiservices.Post <ZoomDataItem>( MethodsHelper.GetUrlAPI(), "/api", "/ZoomDatas", mainViewModel.Token.TokenType, mainViewModel.Token.AccessToken, zoomDataItem); if (!response.IsSuccess) { // Define control format SetStatusControl(true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Add new record cantvViewModel.LoadUserData(); // Define control format this.SetStatusControl(true, false, 0); // Navigate to back await this.navigationService.GoBackOnMaster(); }
private async void Recovery() { var 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; } // Set status controls SetStatusControl(false, true, "Green", 1); response = await apiService.PasswordRecovery( MethodsHelper.GetUrlAPI(), "/api", "/Users/PasswordRecovery", this.Email); 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", "You new password has been successfully sent to email...!!!", "Accept"); // Navigate to LoginPage await navigationService.GoBackOnLogin(); }
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 Login() { // Validate the fields of form var response = MethodsHelper.IsValidField( "S", 0, 0, "email", this.Email, false, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } var isValidEmail = MethodsHelper.IsValidEmail(this.Email); if (!isValidEmail) { await this.dialogService.ShowMessage( "Error", "You must enter an valid email", "Accept"); return; } response = MethodsHelper.IsValidField( "S", 0, 0, "password", this.Password, false, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Establece el estatus de los controles this.SetStatusControl(false, true, true, 1); // Validate if there is an internet connection response = await apiService.CheckConnection(); if (!response.IsSuccess) { // Establece el estatus de los controles this.SetStatusControl(true, true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Get user Token var token = await this.apiService.GetToken( Email, Password, MethodsHelper.GetUrlAPI()); if (token != null) { if (!string.IsNullOrEmpty(token.ErrorDescription)) { // EStablishes the status of controls this.SetStatusControl(true, true, false, 0); await this.dialogService.ShowMessage( "Error", token.ErrorDescription, "Accept"); return; } } else { // Establishes the status of controls this.SetStatusControl(true, true, false, 0); await this.dialogService.ShowMessage( "Error", "An error has occurred, try later...!!!", "Accept"); return; } // Get new instance of ViewModel (Token) this.mainViewModel.Token = token; // Get new instance of MenuViewModel // MainViewModel.GetInstance().Menu = new MenuViewModel(); // Establishes the status of controls this.SetInitialize(); this.SetStatusControl(true, true, false, 0); // Navigate to the page // await navigationService.NavigateOnMaster("MenuPage"); // MainViewModel.GetInstance().Cantv = new CantvViewModel(); this.mainViewModel.Cantv = new CantvViewModel(); // Define the MainPage this.navigationService.SetMainPage("MasterPage"); }
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() { var response = MethodsHelper.IsValidField( "I", 3, 3, "code phone", this.CodePhone, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "I", 7, 7, "number phone", this.NuberPhone, true, false, string.Empty); if (!response.IsSuccess) { await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Define control format SetStatusControl(false, true, 1); response = await apiservices.CheckConnection(); if (!response.IsSuccess) { // Define control format SetStatusControl(true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } this.editCantv.CodePhone = this.CodePhone; this.editCantv.NumberPhone = this.NuberPhone; // Save the data CatvData response = await apiservices.Put <CantvDataItem>( MethodsHelper.GetUrlAPI(), "/api", "/CantvDatas", mainViewModel.Token.TokenType, mainViewModel.Token.AccessToken, this.ToCantvItem(this.editCantv)); if (!response.IsSuccess) { // Define control format SetStatusControl(true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Update record cantvViewModel.UpdateCantvData(0, this.editCantv); // Define control format SetStatusControl(true, false, 0); // Navigate to back await navigationService.GoBackOnMaster(); }
private async void Save() { var response = MethodsHelper.IsValidField( "I", 3, 3, "code phone", this.CodePhone, true, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } response = MethodsHelper.IsValidField( "I", 7, 7, "number phone", this.NuberPhone, true, false, string.Empty); if (!response.IsSuccess) { await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Define control format this.SetStatusControl(false, true, 1); response = await apiservices.CheckConnection(); if (!response.IsSuccess) { // Define control format this.SetStatusControl(true, false, 0); await this.dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } var cantvData = new CantvDataItem { CodePhone = this.CodePhone, NumberPhone = this.NuberPhone, UserId = mainViewModel.UserData.UserId, }; // Save the data CatvData response = await apiservices.Post <CantvDataItem>( MethodsHelper.GetUrlAPI(), "/api", "/CantvDatas", mainViewModel.Token.TokenType, mainViewModel.Token.AccessToken, cantvData); if (!response.IsSuccess) { // Define control format SetStatusControl(true, false, 0); await dialogService.ShowMessage( "Error", response.Message, "Accept"); return; } // Add new record cantvData.CantvDataId = ((CantvData)response.Result).CantvDataId; cantvViewModel.UpdateCantvData( 1, this.ToCantvItemViewModel(cantvData)); // Define control format this.SetStatusControl(true, false, 0); // Navigate to back await this.navigationService.GoBackOnMaster(); }
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"); }