Beispiel #1
0
        public async void Login()
        {
            IsBusy = true;
            Title  = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(_user.Trim()))
                {
                    if (!string.IsNullOrEmpty(_password.Trim()))
                    {
                        //var context = new DbContext();
                        var usr = new { User = "******", Password = "******", Email = "*****@*****.**" };
                        //context.Users.Where(f => f.Name.Equals(_user) || f.Email.Equals(_user)).FirstOrDefault();

                        if (usr?.Password == _password)
                        {
                            Settings.IsLoggedIn = true;
                            await NavigationService.ChangeToPageAsync(new MainPage());
                        }
                        else
                        {
                            Message = "Usuario o contraseña incorrecta";
                        }
                        IsBusy = false;
                    }
                    else
                    {
                        IsBusy  = false;
                        Message = "La contraseña es requerido";
                    }
                }
                else
                {
                    IsBusy  = false;
                    Message = "El email es requerido";
                }
            }
            catch (Exception e)
            {
                IsBusy = false;
                await App.Current.MainPage.DisplayAlert("Error de conexión", e.Message, "Ok");
            }
        }