예제 #1
0
        public async void Login()
        {
            IsBusy = true;
            if (User != null && Password != null)
            {
                usuario = await LoginModel.Authenticate(User, Password);

                if (usuario.UserID > 0)
                {
                    await autoLookViewModel.setLoggedUser(usuario);

                    if (usuario.Type == 2) //Admin = 2
                    {
                        autoLookViewModel.IsAdmin = true;
                    }
                    else
                    {
                        autoLookViewModel.IsAdmin = false;
                    }

                    if (Recordar == true)
                    {
                        UserSystem.DeleteUserRealm(usuario.UserID);
                        UserSystem UserSys = new UserSystem {
                            UserID = usuario.UserID, Email = usuario.Email, Pass = usuario.Password, Remember = true
                        };
                        UserSystem.SaveUserRealm(UserSys);
                    }

                    autoLookViewModel.IsLogged = true;

                    IsBusy = false;

                    await App.Current.MainPage.DisplayAlert("Bienvenido!", usuario.Name + " " + usuario.LastName, "OK");
                }
                else
                {
                    autoLookViewModel.IsLogged = false;
                    await App.Current.MainPage.DisplayAlert("OOOPS", "Error de Login ", "OK");

                    IsBusy = false;
                }
                autoLookViewModel.PageManager(1);
                User     = "";
                Password = "";
                Recordar = false;
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("OOOPS", "Debe completar todos los espacios. ", "OK");

                IsBusy = false;
            }
        }