Пример #1
0
		public async Task<bool> CheckLoginData(LoginModel loginData, string server)
		{
			try {
				RestService restService = new RestService ("/api/login", server);
				var request = await restService.Post (loginData.Username, loginData.Password);
				if (request.StatusCode ==System.Net.HttpStatusCode.NotFound){
					ErrorMessage =Localaizer.Localize("notFoundServer");
					return false;
				}
			} catch (AggregateException e) {
				if (e.InnerExceptions [0].GetType () ==  _platformException.URISyntaxException()) {
					ErrorMessage = Localaizer.Localize("uncorrectURI");
				} else {
					if (e.InnerExceptions [0].Data.Count > 0) {
						ErrorMessage =Localaizer.Localize(e.InnerExceptions [0].Data ["message"].ToString ());
					} else {
						ErrorMessage=Localaizer.Localize("undefinedException");
					}
				}
				//return false;
			}

			_loginModel = new LoginMockModel ();
			return _loginModel.Username == loginData.Username && _loginModel.Password == loginData.Password;
		}
Пример #2
0
        async void onLoginButtonClicked(object sender, EventArgs e)
        {			
            LoginModel loginData = new LoginModel
            {
                Username = _userName.Text,
                Password = _password.Text
            };

			var isValid =await _loginViewModel.CheckLoginData (loginData, ConfigurationManager.SERVER);

			if (isValid)
            {
				await Navigation.PushModalAsync(new VTSListPresenter(_factory, _localize));
            }
            else {
				_password.Text = "";
				_error.Text = (_loginViewModel.ErrorMessage== null)? _localize.Data.loginError:_loginViewModel.ErrorMessage;

                _error.IsVisible = true;
            }
        }
Пример #3
0
		private async void onLoginButtonClicked(object sender, EventArgs e)
		{			
			LoginModel loginData = new LoginModel {
				Username = _userName.Text,
				Password = _password.Text
			};

			var isValid = await _loginViewModel.CheckLoginData (loginData, ConfigurationManager.SERVER);

			if (isValid) {
				Intent intent = new Intent (this, typeof(MainActivity));
				StartActivity (intent);

				await ViewDispose ();
			} else {
				_password.Text = "";

				_error.Text = (_loginViewModel.ErrorMessage == null) ? GetString (Resource.String.loginError) : _loginViewModel.ErrorMessage;
				_error.SetTextColor (Android.Graphics.Color.DarkRed);
				_error.Visibility = ViewStates.Visible;
			}
		}
Пример #4
0
		private async void OnLoginBtnClicked(object sender, EventArgs e)
		{			
			LoginModel loginData = new LoginModel {
				Username = _username.Text,
				Password = _password.Text
			};

			var isValid = await _loginViewModel.CheckLoginData (loginData, ConfigurationManager.SERVER);

			if (isValid) {
				MainViewController mainViewController = this.Storyboard.InstantiateViewController ("MainViewController") as MainViewController;
				if (mainViewController != null) {
					this.NavigationController.PushViewController (mainViewController, true);
				}
			} else {
				_password.Text = "";
				_error.Text = (_loginViewModel.ErrorMessage == null) ? _loginViewModel.Localaizer.Localize("loginError") : _loginViewModel.ErrorMessage;
			}
		}