コード例 #1
0
        /// <summary>
        /// The get user.
        /// </summary>
        /// <param name="loginInfo">
        /// The login Info.
        /// </param>
        /// <returns>
        /// The <see cref="User"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        public User EnterTheSystem(LoginInfo loginInfo)
        {
            User user = this.GetUserOnLogin(loginInfo.Login);

            if (user != null)
            {
                if (loginInfo.Password == user.Password)
                {
                    return user;
                }
                else
                {
                    throw new Exception("User : "******" enter incorrect password.");
                }
            }
            else
            {
                throw new Exception("User " + loginInfo.Login + " not found.");
            }
        }
コード例 #2
0
        /// <summary>
        /// The login.
        /// </summary>
        private void Login()
        {
            try
            {
                this.loginInfo = new LoginInfo();
                this.loginInfo.Login = this.LoginName;
                this.loginInfo.Password = this.Password;

                UserManager userManager = new UserManager();
                User user = userManager.EnterTheSystem(this.loginInfo);

                Application.Current.Properties["UserID"] = user.UserID;

                ControlManager.GetInstance().Place("MainWindow", "mainRegion", "DashboardControl");
            }
            catch (Exception exception)
            {
                // TODO create Exception Base
                this.View.ShowError(exception.ToString());
            }
        }