コード例 #1
0
        public async Task LogIn()
        {
            try
            {
                _duringOperation = true;
                NotifyOfPropertyChange(() => CanLogIn);
                LoginInfoMessage = "Łączenie..";
                AuthenticatedUser user = await _apiHelper.Authenticate(UserName, Password);

                LoginInfoMessage = "";

                await _apiHelper.GetLoggedUserData(user.Access_Token);

                if (RemeberMe)
                {
                    WindowsCredentials.SaveLoginPassword(UserName, Password);
                }
                else
                {
                    WindowsCredentials.DeleteLoginPassword();
                }

                await _eventAggregator.PublishOnUIThreadAsync(new LogOnEvent(reloadNeeded : true), new CancellationToken());

                _duringOperation = false;
                NotifyOfPropertyChange(() => CanLogIn);
            }
            catch (Exception ex)
            {
                _logger.Error("Got exception", ex);
                LoginInfoMessage = ex.Message;
                _duringOperation = false;
                NotifyOfPropertyChange(() => CanLogIn);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        private async Task AuthenticateUser()
        {
            AuthenticatedUser result = await _apiHelper.Authenticate(UserEmail, Password);

            await _apiHelper.GetLoggedInUserInfo(result.Token);

            await _events.PublishOnUIThreadAsync(new LogInEvent());
        }
コード例 #4
0
        //Extended version of CanLogIn
        //public bool CanLogIn
        //{
        //    get
        //    {
        //        bool output = false;
        //        if (UserName?.Length > 0 && Password?.Length > 0)
        //        {
        //            output = true;
        //        }

        //        return output;
        //    }

        //}

        public async Task LogIn()
        {
            try
            {
                var result = await _apiHelper.Authenticate(UserName, Password);
            }
            catch (Exception ex)
            {
                throw new NotImplementedException();
            }
        }
コード例 #5
0
 public async Task LogIn()
 {
     try
     {
         var result = await _apiHelper.Authenticate(UserName, Password);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #6
0
 public async Task LogIn()
 {
     try
     {
         ErrorMessage = "";
         var result = await _apiHelper.Authenticate(UserName, Password);
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
     }
 }
コード例 #7
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();
            }
        }
コード例 #8
0
 public async Task LogIn()
 {
     try
     {
         ErrorMessage = "";
         var result = await _apiHelper.Authenticate(UserName, Password);
     }
     catch (Exception ex)
     {
         //TODO: Flush out different exception possibilities.
         ErrorMessage = ex.Message;
         throw;
     }
 }
コード例 #9
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;
            }
        }
コード例 #10
0
        public async Task LogIn( )
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                //Todo: here we need to put a bearer token so we know the info of the user like username and token.
            }
            catch (Exception ex)
            {
                //throw;
                ErrorMessage = ex.Message;
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
0
        public async Task Submit()
        {
            dynamic settings = new ExpandoObject();

            settings.WindowStartupLocationLocation = WindowStartupLocation.CenterOwner;
            settings.ResizeMode = ResizeMode.NoResize;
            try
            {
                RegisterModel registerModel = new RegisterModel
                {
                    Email           = Email,
                    Password        = Password,
                    ConfirmPassword = ConfirmPassword
                };

                //string createSuccess = await _apiHelper.RegisterUser(Email, Password, ConfirmPassword);
                string createSuccess = await _apiHelper.RegisterUser(registerModel);

                if (createSuccess == "success")
                {
                    var result = await _apiHelper.Authenticate(Email, Password);

                    UserModel     user   = new UserModel();
                    List <string> UInfor = await _apiHelper.GetUserId(result.Access_Token);

                    user.Id           = UInfor[0];
                    user.FirstName    = FirstName;
                    user.LastName     = LastName;
                    user.EmailAddress = Email;
                    user.CreatedDate  = DateTime.Now;

                    await _apiHelper.PostUserInfo(user);


                    settings.Title = "System Message";
                    _status.UpdateMessage("Account Created Successfully", $"{FirstName} Thank you for joining us!");
                    await _window.ShowDialogAsync(_status, null, settings);

                    await _events.PublishOnUIThreadAsync(new LogInEvent());
                }
            }
            catch (Exception ex)
            {
                settings.Title = "System Error";
                _status.UpdateMessage("Fatal Exception", ex.Message);
                _window.ShowDialogAsync(_status, null, settings);
            }
        }
コード例 #13
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";
            }
        }
コード例 #14
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;
            }
        }
コード例 #15
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;
            }
        }
コード例 #16
0
        public async Task LogIn()
        {
            try
            {
                var result = await _apiHelper.Authenticate(UserName, Password);

                // Capture more information bout user
                await _apiHelper.GetLogedInUserInfo(result.Access_Token);

                _events.PublishOnUIThread(new LogOnEvent());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #17
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;
            }
        }
コード例 #18
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;
            }
        }
コード例 #19
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;
            }
        }
コード例 #20
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;
            }
        }
コード例 #21
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;
            }
        }
コード例 #22
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());
            }
        }
コード例 #24
0
        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;
            }
        }
コード例 #25
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;
            }
        }
コード例 #26
0
ファイル: LoginViewModel.cs プロジェクト: vladtf/ReportView
        public async Task Login()
        {
            try
            {
                ErrorMessage = "";
                var result = await _apiHelper.Authenticate(UserName, Password);

                User = await _apiHelper.GetUserInfo(result.access_token);

                User.access_token = result.access_token;

                Console.WriteLine(Event.Name);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
コード例 #27
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;
            }
        }
コード例 #28
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;
            }
        }
コード例 #29
0
        //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;
            }
        }
コード例 #30
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;
            }
        }