Ejemplo n.º 1
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = string.Empty;
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more information about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogInOutEvent { IsLogin = true });
            }
            catch (HttpRequestException ex)
            {
                ErrorMessage = "Connection to server failed";
                Logger.LogError(ex, LogAction.LogOnly);
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("Bad Request"))
                {
                    ErrorMessage = "Wrong Username or Password";
                }
                else
                {
                    ErrorMessage = ex.Message;
                }
                Logger.LogError(ex, LogAction.LogOnly);
            }
        }
        private async Task AuthenticateUser()
        {
            AuthenticatedUser result = await _apiHelper.Authenticate(UserEmail, Password);

            await _apiHelper.GetLoggedInUserInfo(result.Token);

            await _events.PublishOnUIThreadAsync(new LogInEvent());
        }
Ejemplo n.º 3
0
        public async Task LogIn()
        {
            try
            {
                AuthenticatedUser result = await _APIHelper.Authenticate(UserName, Password);

                await _APIHelper.GetLoggedInUserInfo(result.access_token);
            }
            catch (Exception exc)
            {
                ErrorMsg = exc.Message.ToString();
            }
        }
Ejemplo n.º 4
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 5
0
        public async Task LogIn()
        {
            try
            {
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _eventAggregator.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Ejemplo n.º 6
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message + " Username or password are incorrect";
            }
        }
Ejemplo n.º 7
0
        public async Task Login()
        {
            try
            {
                ErrorMessage = string.Empty;
                var result = await _apiHelper.Authenticate(Username, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _eventAggregator.PublishOnUIThreadAsync(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 8
0
        public async Task Login()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                // Capture more information about the user.

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 9
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogOnEvent(), new CancellationToken());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 10
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = string.Empty;
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more info about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 11
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //capture more information about the user.
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent()); //this tells the user that the user has logged in.
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 12
0
        public async void LogIn(string userName, string password)
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());
            }

            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                // Capture more info about the logged in user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogOnEvent(), new CancellationToken()); // Does nothing just broadcasts that a login event happened.
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 14
0
        public async Task LogIn() //calling an api must be done asynchronously
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //capture more info about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 15
0
        public async Task Login()
        {
            ErrorMessage = string.Empty;
            try
            {
                var result = await _apiHelper.Authenticate(UserName, Password);

                // capture user information
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _event.PublishOnUIThreadAsync(new LogOnEventModel());
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
            }
        }
        public async Task <ActionResult> Login(string UserName, string Password)
        {
            try
            {
                var result = await _aPIHelper.Authenticate(UserName, Password);

                //capture more information about the user
                await _aPIHelper.GetLoggedInUserInfo(result.Access_Token);

                return(RedirectToAction("Sales", "RetailManagement"));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMsg = ex.Message;
                return(View());
            }
        }
Ejemplo n.º 17
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more information about user
                await _apiHelper.GetLoggedInUserInfo(result.AccessToken);

                _events.BeginPublishOnUIThread(new LogOnEventModel());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 18
0
        public async Task LogIn()  //async to not lock your application up
        {
            try
            {
                ErrorMessage = "";
                //the result will be AthunticatedUser model
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more information about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogOnEvent(), new CancellationToken());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Triggers an HTTP request to our API in order to make an authentication usgin the given UserName and Password.
        /// </summary>
        /// <returns></returns>
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more information about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                //Make sure that we're using the UI thread in order to prevent cross threading issues
                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
        //public bool CanLogIn(string userName, string password)
        //{
        //    bool output = false;
        //    if (userName?.Length > 0 && password?.Length > 0)
        //    {
        //        output = true;
        //    }
        //    return output;
        //}

        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                // capture more info about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogOnEvent(), new CancellationToken());
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 21
0
        public async Task Login()
        {
            try
            {
                ErrorMessage = string.Empty;
                AuthenticatedUser result = await _apiHelper.Authenticate(Username, Password);

                // Retrieve the additional information about the user
                await _apiHelper.GetLoggedInUserInfo(result.AccessToken);

                // Push the event for the login
                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
            }
        }
Ejemplo n.º 22
0
        // calling and api calls are asynchronous
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //capture more information about user.
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                //event will  be listend to UI thread.to avoid cross threading issues. Class is subscribing to logon events.
                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 23
0
        public async Task LogIn()
        {
            try
            {
                // error message 없애는 용도
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                // Capture more information about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());    // LogOnEvent가 실행되므로 ShellViewModel의 handle 메서드가 작동한다.
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 24
0
        public async Task Login()
        {
            //string mypassword = "******";
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                //capture more information about the user

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 25
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = String.Empty;
                //1.Authenticate
                var result = await _apiHelper.Authenticate(UserName, Password);

                //2.Capture more information about the user in the model
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                //3. Raise event after user logs in
                _eventAggregator.PublishOnUIThread(new LogOnEventModel());
            }
            catch (Exception exc)
            {
                ErrorMessage = $"*{exc.Message}";
            }
        }
        public async void Handle(AttemptLogin message)
        {
            try
            {
                //ErrorMessage = "";
                _loginCredentialsViewModel.ErrorMessage = "";
                ActivateItem(_preloaderViewModel);
                var result = await _apiHelper.Authenticate(message.Username, message.Password);

                var r = await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                _eventAggregator.PublishOnUIThread(new ValidLoginCredentialsEntered());
            }
            catch (Exception ex)
            {
                ActivateItem(_loginCredentialsViewModel);
                _loginCredentialsViewModel.ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 27
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserEmail, Password);

                // Capture more informations about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _userRallyInfo.GetLoggedInUserRallyInfo();

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 28
0
        public async Task LogIn()
        {
            ActiveControls = false;
            ErrorMessage   = "";

            try
            {
                var result = await apiHelper.Authenticate(UserName, Password);

                await apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await events.PublishOnUIThreadAsync(new LogOnEventModel());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }

            ActiveControls = true;
        }
Ejemplo n.º 29
0
    public async Task LogIn()
    {
        try
        {
            string un = UserName.text;
            string pw = Password.text;
            ErrorMessage = "";
            var result = await _apiHelper.Authenticate(un, pw);

            Debug.Log("User Authenticated" + result);
            await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

            //_events.GetEvent<LogOnEvent>().Publish();
            LoggedIn?.Invoke();
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
        }
    }
Ejemplo n.º 30
0
        public async Task LogIn()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Capture more information about the user
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                //Just to update that an event has happened and Shell View model will listen to that event
                //(Will make some changes in shellview)
                //Below line will trigger Handle method containing LogOnEvent as parameter in ShellView
                await _events.PublishOnUIThreadAsync(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }