private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( "Error1", "Insert an email", "Accept"); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "Insert your password", "Accept"); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = true; this.IsEnabled = false; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Accept"); return; } var token = await this.apiService.GetToken( "http://webapixamarin-001-site1.atempurl.com", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Something was wrong, please try later.", "Accept"); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Accept"); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void Register() { MainViewModel.GetInstance().Register = new RegisterViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new RegisterPage()); }
private async void ChangePassword() { if (string.IsNullOrEmpty(this.CurrentPassword)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } if (this.CurrentPassword.Length < 6) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation2, Languages.Accept); return; } if (this.CurrentPassword != MainViewModel.GetInstance().User.Password) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordError, Languages.Accept); return; } if (string.IsNullOrEmpty(this.NewPassword)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } if (this.NewPassword.Length < 6) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation2, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Confirm)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.ConfirmValidation, Languages.Accept); return; } if (this.NewPassword != this.Confirm) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.ConfirmValidation2, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var request = new ChangePasswordRequest { CurrentPassword = this.CurrentPassword, Email = MainViewModel.GetInstance().User.Email, NewPassword = this.NewPassword, }; var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.ChangePassword( apiSecurity, "/api", "/Users/ChangePassword", MainViewModel.GetInstance().Token.TokenType, MainViewModel.GetInstance().Token.AccessToken, request); if (!response.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.ErrorChangingPassword, Languages.Accept); return; } MainViewModel.GetInstance().User.Password = this.NewPassword; this.dataService.Update(MainViewModel.GetInstance().User); this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.ConfirmLabel, Languages.ChagePasswordConfirm, Languages.Accept); await App.Navigator.PopAsync(); }
private async void LoadServicios() { var tokin = MainViewModel.GetInstance().Mitoken; var alumnoactual = MainViewModel.GetInstance().hijo; var centro = MainViewModel.GetInstance().Centro; var CalendarioACT = MainViewModel.GetInstance().GrillaCalendario; this.IsRefreshing = true; var connection = await this.apiService.CheckConnection(); var mimes = "0" + CalendarioACT.Mesactual; var hayservicios = 0; // para meterle el 0 en el mes if (mimes.Length == 2) { mimes = mimes.Substring(0, 2); } else { mimes = mimes.Substring(1, 2); } // var f1 = CalendarioACT.Anyactual + "-" + mimes + "-" + "01"; // if (!connection.IsSuccess) // { // this.IsRefreshing = false; // await Application.Current.MainPage.DisplayAlert( // Languages.Error, // connection.Message, // Languages.Accept); // await Application.Current.MainPage.Navigation.PopAsync(); // return; // } //var apiLands = Application.Current.Resources["APILands"].ToString(); var response1 = await this.apiService.CogeServiciosMes <Servicio>( "https://comocomen.com/main_control/servidor_ws.php", tokin.AccessToken, centro, alumnoactual.Num_expediente, f1, "0"); if (response1.IsSuccess == false) { hayservicios = 0; } else { hayservicios = 1; MainViewModel.GetInstance().ServiciosListMes = (List <Servicio>)response1.Result; } MainViewModel.GetInstance().ServiciosList = (List <Servicio>)response1.Result; this.Hijoactual = MainViewModel.GetInstance().hijo; this.IsRefreshing = false; this.Servicios = new ObservableCollection <ServicioItemViewModel>( this.ToServicioItemViewModel()); this.IsRefreshing = false; var kk = Hijoactual; var ll = "hh"; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await dialogService.ShowMessage( "Error", "You must enter an email...!!!", "Accept"); return; } if (string.IsNullOrEmpty(this.Password)) { await dialogService.ShowMessage( "Error", "You must enter an password...!!!", "Accept"); return; } //if (this.Email != "*****@*****.**" // || this.Password != "*****@*****.**") //{ // await dialogService.ShowMessage( // "Error", // "Email or password incorrect...!!!", // "Accept" // ); // SetInitialize(); // return; //} SetStatusControls(false, true, true); var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { SetStatusControls(true, false, true); await dialogService.ShowMessage( "Erros", connection.Message, "Accept"); return; } // Optiene el Token del usuario var token = await this.apiService.GetToken( "http://chejconsultor.ddns.net:9015/", this.Email, this.Password); if (token == null || !string.IsNullOrEmpty(token.ErrorDescription)) { SetStatusControls(true, false, true); await dialogService.ShowMessage( "Error", string.IsNullOrEmpty(token.ErrorDescription)? "Something was wrong, please try later...!!!" : token.ErrorDescription, "Accept"); return; } // Asigna el estaus de los controles SetStatusControls(true, false, true); // Inicializa los controles SetInitialize(); // Guarda en persistenacia la informacion del Token MainViewModel.GetInstance().Token = token; // Genera una instancia del LandsViewModel MainViewModel.GetInstance().Lands = new LandsViewModel(); // await Application.Current.MainPage.Navigation.PushAsync( // new LandsPage()); await navigationService.Navigate("LandsPage"); //await dialogService.ShowMessage( //"Information", //"Access is ok...!!!", //"Accept"); }
private async void Save() { if (string.IsNullOrEmpty(this.User.FirstName)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.FirstNameValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.User.LastName)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.LastNameValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.User.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (!RegexUtilities.IsValidEmail(this.User.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation2, Languages.Accept); return; } if (string.IsNullOrEmpty(this.User.Telephone)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PhoneValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var checkConnetion = await this.apiService.CheckConnection(); if (!checkConnetion.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, checkConnetion.Message, Languages.Accept); return; } byte[] imageArray = null; if (this.file != null) { imageArray = FilesHelper.ReadFully(this.file.GetStream()); } var userDomain = Conveter.ToUserDomain(this.User, imageArray); var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.Put( apiSecurity, "/api", "/Users", //MainViewModel.GetInstance().TokenType, //MainViewModel.GetInstance().Token, MainViewModel.GetInstance().Token.TokenType, MainViewModel.GetInstance().Token.AccessToken, userDomain); if (!response.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, response.Message, Languages.Accept); return; } var userApi = await this.apiService.GetUserByEmail( apiSecurity, "/api", "/Users/GetUserByEmail", //MainViewModel.GetInstance().TokenType, //MainViewModel.GetInstance().Token, MainViewModel.GetInstance().Token.TokenType, MainViewModel.GetInstance().Token.AccessToken, this.User.Email); var userLocal = Conveter.ToUserLocal(userApi); MainViewModel.GetInstance().User = userLocal; this.dataService.Update(userLocal); this.IsRunning = false; this.IsEnabled = true; await App.Navigator.PopAsync(); }
private IEnumerable <ServicioItemViewModel> ToServicioItemViewModel() { return(MainViewModel.GetInstance().ServiciosList.Select(l => new ServicioItemViewModel { Codservicio = l.Codservicio, Tipoasistencia = l.Tipoasistencia, Diasasistencia = l.Diasasistencia, Numeroasistencias = l.Numeroasistencias, Codmesa = l.Codmesa, Codturno = l.Codturno, Nombreservicio = l.Nombreservicio, Nombreturno = l.Nombreturno, Fecha = l.Fecha, conmenu = l.conmenu, Tipocomidas = l.Tipocomidas, FechaCambio = l.FechaCambio, Monitores = l.Monitores, Dia = l.Dia, Mes = l.Mes, Any = l.Any, Iconoasistencia = l.Iconoasistencia, Iconoausencia = l.Iconoausencia, Avisoasistencia = l.Avisoasistencia, Avisodieta = l.Avisodieta, Avisoausencia = l.Avisoausencia, entrante1 = l.entrante1, nombremenu1 = l.nombremenu1, primerplato1 = l.primerplato1, segundoplato1 = l.segundoplato1, elmenu = l.elmenu, postre1 = l.postre1, sinmenu = l.sinmenu, tieneacesso = l.tieneacesso, notieneacesso = l.notieneacesso, Coloracceso = l.Coloracceso, modelo1 = l.modelo1, modelo2 = l.modelo2, Pulsato = l.Pulsato, Accesotxt = l.Accesotxt, Cantidadplato1 = l.Cantidadplato1, Cantidadplato2 = l.Cantidadplato2, Cantidadplato3 = l.Cantidadplato3, Cantidadplato4 = l.Cantidadplato4, Infonutrimenu = l.Infonutrimenu, Infonutriplato1 = l.Infonutriplato1, Infonutriplato2 = l.Infonutriplato2, Infonutriplato3 = l.Infonutriplato3, Infonutriplato4 = l.Infonutriplato4, Mencomidas = l.Mencomidas, Nomgrupomenu = l.Nomgrupomenu, Nommenu = l.Nommenu, Nomplato1 = l.Nomplato1, Nomplato2 = l.Nomplato2, Nomplato3 = l.Nomplato3, Nomplato4 = l.Nomplato4, Numplatos = l.Numplatos, Obscomidas = l.Obscomidas, Codgrupomenu = l.Codgrupomenu, Codigotipoasistencia = l.Codigotipoasistencia, Flag = l.Flag, Sercomidas = l.Sercomidas, Tienemenu = l.Tienemenu, Tipoplato1 = l.Tipoplato1, Tipoplato2 = l.Tipoplato2, Tipoplato3 = l.Tipoplato3, Tipoplato4 = l.Tipoplato4, Iconoestrella1 = l.Iconoestrella1, Iconoestrella2 = l.Iconoestrella2, Iconoestrella3 = l.Iconoestrella3, Iconoestrella4 = l.Iconoestrella4, })); }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( "Error", "Introduzca su correo", "Aceptar"); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "Introduzca su password", "Aceptar"); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Aceptar"); return; } var token = await this.apiService.GetToken( "https://productosi220.azurewebsites.net", this.Email, this.Password); if(token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Error de token intentelo mas tarde", "Aceptar"); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Aceptar"); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var token = await this.apiService.GetToken( apiSecurity, this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Accept); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, token.ErrorDescription, Languages.Accept); this.Password = string.Empty; return; } var user = await this.apiService.GetUserByEmail( apiSecurity, "/api", "/Users/GetUserByEmail", token.TokenType, token.AccessToken, this.Email); var userLocal = Converter.ToUserLocal(user); var mainViewModel = MainViewModel.GetInstance(); //guardando el token en memoria de la aplicación mainViewModel.Token = token.AccessToken; mainViewModel.TokenType = token.TokenType; mainViewModel.User = userLocal; if (this.IsRemembered) { //Guardando los token en persistencia, es decir en la memoria del teléfono Settings.Token = token.AccessToken; Settings.TokenType = token.TokenType; //Guardando los datos del usuario en local, para que se siga mostrando en la aplicación todos los datos //cuando estemos logueados, entonces borramos el usuario que haya creado e insertamos el usuario con el que nos loguiemos o //nos vayamos a loguear this.dataService.DeleteAllAndInsert(userLocal); } mainViewModel.Lands = new LandsViewModel(); Application.Current.MainPage = new MasterPage();//Esta forma de navegación es para que no se pueda devolver con el //botón de atrás //await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void Login() // Metodo asyncrono { // using Xamarin.Forms; if (string.IsNullOrEmpty(this.Email)) { // using Xamarin.Forms; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Psswd)) { // using Xamarin.Forms; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; // Hacer token al servicio API var conection = await this.apiService.CheckConnection(); if (!conection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", conection.Message, "Accept"); return; } var token = await this.apiService.GetToken( "https://landsapidr.azurewebsites.net", this.Email, this.Psswd); //Error al consumir el servicio if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Somethings was wrong, please try again.", "Accept"); return; } if (string.IsNullOrEmpty(token.TokenType)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Accept"); this.Psswd = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; // Navegar a la siguiente pagina mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPages()); this.IsRunning = false; this.IsEnabled = true; //this.Email = string.Empty; this.Psswd = string.Empty; }
private async void Navigate() { // App.Master.IsPresented = false; if (this.PageName == "LoginPage") { // Settings.IsRemembered = "false"; // var mainViewModel = MainViewModel.GetInstance(); // mainViewModel.Token = null; // mainViewModel.User = null; // MainViewModel.GetInstance().Menus.Add(new MenuItemViewModel // { // Icon = "ic_exit_to_app", // PageName = "LoginPage", // Title = Languages.LogOut, // }); Application.Current.MainPage = new NavigationPage( new LoginPage()); } // if (this.PageName == "AlumnoTabbedPage") // { // Settings.IsRemembered = "false"; // var seleccion = MainViewModel.GetInstance().AlumnosList.Select(l => new AlumnoItemViewModel foreach (Hijo item in (MainViewModel.GetInstance().AlumnosList)) { if (item.Cod_alum == this.PageName) { this.mialumno = item; } } MainViewModel.GetInstance().Alumno = new AlumnoViewModel(this.mialumno); // await Application.Current.MainPage.DisplayActionSheet("hola",null,null); // await task. Application.Current.MainPage.DisplayActionSheet("") using (UserDialogs.Instance.Loading("Cargando..", null, null, true, MaskType.Black)) { await Task.Delay(3000); } using (UserDialogs.Instance.Loading("Cargando..", null, null, true, MaskType.Black)) { await App.Navigator.PushAsync(new AlumnoTabbedPage()); App.Master.IsPresented = false; } // App.Navigator.PushAsync(new AlumnoTabbedPage()); return; // var mainViewModel = MainViewModel.GetInstance(); // App.Navigator.PushAsync(new CargandoPage()); // MainViewModel.GetInstance().Cargando = new CargandoViewModel(); // Application.Current.MainPage = new CargandoPage(); // } // else if (this.PageName == "MyProfilePage") // { // MainViewModel.GetInstance().MyProfile = new MyProfileViewModel(); // App.Navigator.PushAsync(new MyProfilePage()); // } }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; //this.IsRefreshing = false; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var token = await this.apiService.GetToken( apiSecurity, this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token.AccessToken; mainViewModel.ToketType = token.TokenType; if (this.IsRemembered) { Settings.Token = token.AccessToken; Settings.TokenType = token.TokenType; } mainViewModel.Lands = new LandsViewModel(); Application.Current.MainPage = new MasterPage(); //await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); //if (this.Email != "*****@*****.**" || this.Password != "12345") //{ // this.IsRunning = false; // this.IsEnabled = true; // await Application.Current.MainPage.DisplayAlert( // "Error", // "Email or Password is incorrect", // "Accept"); // this.Password = string.Empty; // return; //} this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void LoginMethod() { IsRunning = true; IsEnable = false; if (string.IsNullOrEmpty(this.Email)) { await App.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Ok); this.Password = string.Empty; IsRunning = false; IsEnable = true; return; } if (string.IsNullOrEmpty(this.Password)) { await App.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Ok); this.Password = string.Empty; IsRunning = false; IsEnable = true; return; } var conection = await this.apiService.CheckConnection(); if (!conection.IsSuccess) { IsRunning = false; IsEnable = true; await App.Current.MainPage.DisplayAlert( Languages.Error, conection.Message, Languages.Ok); this.Password = string.Empty; return; } var token = await this.apiService.GetToken( "http://landsapi1.azurewebsites.net", this.Email, this.Password); if (token == null) { IsRunning = false; IsEnable = true; await App.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Ok); this.Password = string.Empty; return; } if (string.IsNullOrEmpty(token.AccessToken)) { IsRunning = false; IsEnable = true; await App.Current.MainPage.DisplayAlert( Languages.Error, token.ErrorDescription, Languages.Ok); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await App.Current.MainPage.Navigation.PushAsync(new Views.LandsPage()); IsRunning = false; IsEnable = true; Password = string.Empty; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter an email.", "Accept"); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter an password.", "Accept"); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Accept"); return; } var token = await this.apiService.GetToken( "", this.Email, this.Password); if (this.Email != "*****@*****.**" || this.Password != "Hola1234.") { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Email or password incorrect.", "Accept"); this.Password = string.Empty; return; } this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; MainViewModel.GetInstance().Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept);; return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var token = await this.apiService.GetToken( apiSecurity, this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Accept); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.LoginError, Languages.Accept); this.Password = string.Empty; return; } var user = await this.apiService.GetUserByEmail( apiSecurity, "/api", "/Users/GetUserByEmail", token.TokenType, token.AccessToken, this.Email); var userLocal = Converter.ToUserLocal(user); userLocal.Password = this.Password; var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.User = userLocal; if (this.IsRemembered) { Settings.IsRemembered = "true"; } else { Settings.IsRemembered = "false"; } this.dataService.DeleteAllAndInsert(userLocal); this.dataService.DeleteAllAndInsert(token); mainViewModel.Lands = new LandsViewModel(); Application.Current.MainPage = new MasterPage(); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
public AvisosalumnoViewModel() { this.HijoActual = MainViewModel.GetInstance().hijo.Nom_alum + " " + MainViewModel.GetInstance().hijo.Apellido1 + " " + MainViewModel.GetInstance().hijo.Apellido2; this.Expedienteactual = MainViewModel.GetInstance().hijo.Num_expediente; this.familia = MainViewModel.GetInstance().Familiadata; var kk = "kk"; this.apiService = new ApiService(); this.LoadAvisos(); //this.Filtra(); }
private async void SelectAlumno() { MainViewModel.GetInstance().Alumno = new AlumnoViewModel(this); await App.Navigator.PushAsync(new AlumnoPage()); }
private async void SelectLand() { MainViewModel.GetInstance().Land = new LandViewModel(this); await App.Navigator.PushAsync(new LandTabbedPage()); }
private async void ChangePassword() { MainViewModel.GetInstance().ChangePassword = new ChangePasswordViewModel(); await App.Navigator.PushAsync(new ChangePasswordPage()); }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept ); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept ); return; } this.IsRunning = true; this.IsEnabled = false; /* * if (this.Email != "*****@*****.**" || this.Password != "1234") * { * this.IsRunning = false; * this.IsEnabled = true; * await Application.Current.MainPage.DisplayAlert( * "Error", * "Email or password incorrect", * "Accept" * ); * this.Password = string.Empty; * return; * } */ var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept ); this.Password = string.Empty; return; } var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var token = await this.apiService.GetToken( apiSecurity, this.Email, this.Password ); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.TokenValidation, Languages.Accept ); this.Password = string.Empty; return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.LoginError, Languages.Accept ); this.Password = string.Empty; return; } var user = await this.apiService.GetUserByEmail( apiSecurity, "/api", "/Users/GetUserByEmail", token.TokenType, token.AccessToken, this.Email ); var userLocal = Converter.ToUserLocal(user); userLocal.Password = this.Password; var mainViewmodel = MainViewModel.GetInstance(); mainViewmodel.Token = token; // Lo guardamos en memoria (en la mainViewModel) mainViewmodel.User = userLocal; if (this.IsRemembered) { Settings.IsRemembered = "true"; // Lo guardamos tambien en la Settings (Persistencia) } else { Settings.IsRemembered = "false"; // Lo guardamos tambien en la Settings (Persistencia) } this.dataService.DeleteAllAndInsert(userLocal); //sqlite this.dataService.DeleteAllAndInsert(token); //sqlite mainViewmodel.Lands = new LandsViewModel(); //await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); Application.Current.MainPage = new MasterPage(); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
public ServiciosViewModel() { this.Nomcompleto = MainViewModel.GetInstance().hijo.Nom_alum.ToUpper() + " " + MainViewModel.GetInstance().hijo.Apellido1.ToUpper() + " " + MainViewModel.GetInstance().hijo.Apellido2.ToUpper(); // this.Nomcompleto = MainViewModel.GetInstance().hijo.Nom_alum + " " + MainViewModel.GetInstance().hijo.Apellido1 + " " + MainViewModel.GetInstance().hijo.Apellido2; this.apiService = new ApiService(); // this.LoadServicios(); }
private async void Login() { if (string.IsNullOrEmpty(Email)) { await Application.Current.MainPage.DisplayAlert( "Error", "Debes ingresar el email", "Aceptar"); return; } if (string.IsNullOrEmpty(Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "Debes ingresar el password", "Aceptar"); return; } this.IsRunning = true; this.IsEnabled = false; //if (this.Email != "*****@*****.**" || this.Password != "Admin2.0") //{ // this.IsRunning = false; // this.IsEnabled = true; // await Application.Current.MainPage.DisplayAlert( // "Error", // "Las credenciales son incorrectas", // "Aceptar"); // this.Password = string.Empty; // return; //} var connection = await services.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Aceptar"); return; } var token = await this.services.GetToken( "http://lonapi.azurewebsites.net", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Ha ocurrido un error intentelo de nuevo", "Aceptar"); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Aceptar"); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; /*await Application.Current.MainPage.DisplayAlert( * "Ingreso", * "Bienvenido a mi app", * "Aceptar"); */ this.Email = string.Empty; this.Password = string.Empty; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter an email.", "Accept"); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter a password.", "Accept"); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiservice.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Accept"); return; } var token = await this.apiservice.GetToken("http://landsapi1.azurewebsites.net", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Something was wrong, please try again", "Accept"); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Accept"); this.password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter an email.", "Accept" ); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter a password.", "Accept" ); return; } this.IsRunning = true; this.IsEnabled = false; /*if (this.Email != "*****@*****.**" || this.Password != "1234") * { * this.IsRunning = false; * this.IsEnabled = true; * await Application.Current.MainPage.DisplayAlert( * "Error", * "Email or password incorrect.", * "Accept" * ); * * this.Password = string.Empty; * * return; * }*/ var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Accept" ); return; } var token = await this.apiService.GetToken( "url base de la pagina publicada de API", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", "Something went wrong :(, please try later.", "Accept" ); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( "Error", token.ErrorDescription, "Accept" ); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; //if (this.Email != "*****@*****.**" || this.Password != "1234") //{ // this.IsRunning = false; // this.IsEnabled = true; // await Application.Current.MainPage.DisplayAlert( // "Error", // "Email or pasword incorrect.", // "Accept"); // this.Password = string.Empty; // return; //} var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var token = await this.apiService.GetToken( apiSecurity, this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Accept); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, token.ErrorDescription, Languages.Accept); this.Password = string.Empty; return; } var user = await this.apiService.GetUserByEmail( apiSecurity, "/api", "/Users/GetUserByEmail", this.Email); var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token.AccessToken; mainViewModel.TokenType = token.TokenType; mainViewModel.User = user; if (this.IsRemembered) { Settings.Token = token.AccessToken; Settings.TokenType = token.TokenType; } mainViewModel.Lands = new LandsViewModel(); Application.Current.MainPage = new MasterPage(); this.IsRunning = false; this.IsEnabled = true; //await Application.Current.MainPage.DisplayAlert( // "Error", // "dale.", // "Accept"); this.Email = string.Empty; this.Password = string.Empty; }
public ActividadesViewModel() { this.Nomcompleto = MainViewModel.GetInstance().hijo.Nom_alum + " " + MainViewModel.GetInstance().hijo.Apellido1 + " " + MainViewModel.GetInstance().hijo.Apellido2; this.apiService = new ApiService(); // this.LoadActividades(); this.CogeActividades(); }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.Accept, Languages.Accept); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = true; this.IsEnabled = false; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); return; } var token = await this.apiService.GetToken( "http://webapixamarin-001-site1.atempurl.com", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, "Something was wrong, please try later.", Languages.Accept); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, token.ErrorDescription, Languages.Accept); this.Password = string.Empty; return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token.AccessToken; mainViewModel.TokenType = token.TokenType; if (this.IsRemembered) { Settings.Token = token.AccessToken; Settings.TokenType = token.TokenType; } mainViewModel.Lands = new LandsViewModel(); Application.Current.MainPage = new MasterPage(); this.IsRunning = false; this.IsEnabled = true; this.Email = string.Empty; this.Password = string.Empty; }
private async void LoadActividades() { var tokin = MainViewModel.GetInstance().Mitoken; var alumnoactual = MainViewModel.GetInstance().hijo; var centro = MainViewModel.GetInstance().Centro; var diaactualtmp = $"{DateTime.Now.Day}"; var diaactual = "0" + diaactualtmp; // para meterle el 0 en el dia if (diaactual.Length == 2) { diaactual = diaactual.Substring(0, 2); } else { diaactual = diaactual.Substring(1, 2); } // var mesactualtmp = $"{DateTime.Now.Month}"; var mesactual = "0" + mesactualtmp; // para meterle el 0 en el dia if (mesactual.Length == 2) { mesactual = mesactual.Substring(0, 2); } else { mesactual = mesactual.Substring(1, 2); } // var fechaactual = $"{DateTime.Now.Year}" + mesactual + diaactual; this.IsRefreshing = true; var connection = await this.apiService.CheckConnection(); // if (!connection.IsSuccess) // { // this.IsRefreshing = false; // await Application.Current.MainPage.DisplayAlert( // Languages.Error, // connection.Message, // Languages.Accept); // await Application.Current.MainPage.Navigation.PopAsync(); // return; // } //var apiLands = Application.Current.Resources["APILands"].ToString(); var response = await this.apiService.CogeActividades <Actividad>( "https://comocomen.com/main_control/servidor_ws.php", tokin.AccessToken, centro, alumnoactual.Num_expediente, fechaactual); if (!response.IsSuccess) { this.IsRefreshing = false; await Application.Current.MainPage.DisplayAlert( Languages.Error, response.Message, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } MainViewModel.GetInstance().ActividadesList = (List <Actividad>)response.Result; this.Hijoactual = MainViewModel.GetInstance().hijo; this.IsRefreshing = false; this.Actividades = new ObservableCollection <ActividadItemViewModel>( this.ToActividadItemViewModel()); this.IsRefreshing = false; var kk = Hijoactual; var ll = "hh"; }
private async void SelectLand() { MainViewModel.GetInstance().Land = new LandViewModel(this); //await App.Current.MainPage.Navigation.PushAsync(new LandPage()); await App.Current.MainPage.Navigation.PushAsync(new LandTabbedPage()); }
private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailValidation, Languages.Accept); return; } else { try { MailAddress m = new MailAddress(this.Email); } catch (FormatException) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.EmailType, Languages.Accept); return; } } if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.PasswordValidation, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } this.IsRunning = true; this.IsEnabled = false; var connection = await this.apiServices.CheckConnection(); if (!connection.IsSuccess) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, connection.Message, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } var token = await this.apiServices.GetToken( "http://landsapi.azurewebsites.net", this.Email, this.Password); if (token == null) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } if (string.IsNullOrEmpty(token.AccessToken)) { this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.Error, Languages.SomethingWrong, Languages.Accept); await Application.Current.MainPage.Navigation.PopAsync(); return; } var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Token = token; mainViewModel.Lands = new LandsViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LandsPage()); this.IsRunning = false; this.IsEnabled = true; this.Email = String.Empty; this.Password = String.Empty; }