Ejemplo n.º 1
0
        /// <summary>
        /// Авторизация после успешной регистарции
        /// </summary>
        /// <param name="login"></param>
        /// <param name="password"></param>
        void LoginAfterRegistration(string login, string password)
        {
            try
            {
                var user = videoStore.GetUser(login, password).FirstOrDefault();

                if (user == null)
                {
                    errorMassageTextBox.Text       = "Неверный логин или пароль";
                    errorMassageTextBox.Visibility = Visibility.Visible;
                    return;
                }
                else
                {
                    CurrentUser.SetUserInfo(user.UserID, user.UserName, user.UserSurname, user.UserMiddleName, user.CardBalance, user.CardNumber, user.RegisterDate);

                    userInfoName.Text    = $"{CurrentUser.UserSurname} {CurrentUser.UserName} {CurrentUser.UserMiddlename}";
                    userInfoBalance.Text = CurrentUser.CardBalance.ToString();
                    userInfo.Visibility  = Visibility.Visible;

                    loginButton.Visibility  = Visibility.Collapsed;
                    logoutButton.Visibility = Visibility.Visible;

                    userInfoPage = new UserInfoPage(videoStore);

                    AppUpdate.Update();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ClearLoginFormValues();
                HideErrors();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Авторизация
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var user = videoStore.GetUser(loginNameTextBox.Text, loginPasswordBox.Password).FirstOrDefault();

                if (user == null)
                {
                    errorMassageTextBox.Text       = "Неверный логин или пароль";
                    errorMassageTextBox.Visibility = Visibility.Visible;
                    return;
                }
                else
                {
                    CurrentUser.SetUserInfo(user.UserID, user.UserName, user.UserSurname, user.UserMiddleName, user.CardBalance, user.CardNumber, user.RegisterDate);

                    userInfoName.Text    = $"{CurrentUser.UserSurname} {CurrentUser.UserName} {CurrentUser.UserMiddlename}";
                    userInfoBalance.Text = CurrentUser.CardBalance.ToString();
                    userInfo.Visibility  = Visibility.Visible;

                    loginButton.Visibility  = Visibility.Collapsed;
                    logoutButton.Visibility = Visibility.Visible;

                    DialogWindowLogin.IsOpen = false;

                    ClearLoginFormValues();
                    userInfoPage = new UserInfoPage(videoStore);

                    AppUpdate.Update();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }