Пример #1
0
        private async void Login()
        {
            if (string.IsNullOrEmpty(Email))
            {
                await dialogService.ShowMessage("Error", "Debe ingresar un Usuario.");

                return;
            }

            if (string.IsNullOrEmpty(Password))
            {
                await dialogService.ShowMessage("Error", "Debe ingresar una Contraseña.");

                return;
            }

            IsRunning = true;
            IsEnabled = false;



            if (!CrossConnectivity.Current.IsConnected)
            {
                IsRunning = false;
                IsEnabled = true;
                await dialogService.ShowMessage("Error", "Chequee su conexión a Internet.");

                return;
            }

            //var parameters = dataService.First<Parameter>(false);

            var response = await apiService.GetUserByEmail(
                "http://keypress.serveftp.net:88/MutualMyPJHPAPI/",
                "api",
                "/Usuarios/GetUserByEmail",
                Email);



            if (!response.IsSuccess)
            {
                IsRunning = false;
                IsEnabled = true;
                await dialogService.ShowMessage("Error", "El Usuario o Contraseña son incorrectos");

                return;
            }

            var user = (Usuario)response.Result;


            if (!(user.Password.ToLower() == Password.ToLower()))
            {
                IsRunning = false;
                IsEnabled = true;
                await dialogService.ShowMessage("Error", "El Usuario o Contraseña son incorrectos");

                return;
            }



            //user.IsRemembered = IsRemembered;
            //user.Contrasena = Password;
            //dataService.DeleteAllAndInsert(user);

            Email    = null;
            Password = null;

            IsRunning = false;
            IsEnabled = true;


            var mainViewModel = MainViewModel.GetInstance();

            mainViewModel.CurrentUser = user;
            navigationService.SetMainPage("MasterPage");
        }