Exemple #1
0
        public static ConnectionUser Instance()
        {
            if (connUser == null)
            {
                connUser = new ConnectionUser();
            }

            return(connUser);
        }
Exemple #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (usernameTextBox.Text == "" || passwordBox.Password == "")
            {
                MessageBox.Show("None field can be empty!");
                return;
            }

            User user = null;

            client = new WCFClient(binding, address, usernameTextBox.Text);

            UserRole result = client.LogIn(usernameTextBox.Text, passwordBox.Password, out user);

            if (result == UserRole.unauthenticated)
            {
                MessageBox.Show(String.Format("User with username: {0}, does not exits or username/password combination is not right", usernameTextBox.Text));
                Audit.AnnotateEvent(String.Format("Error while login with username {0} and password {1}", usernameTextBox.Text, passwordBox.Password));
            }
            else
            {
                ConnectionUser.Instance().CurrentUser = user;
            }

            if (ConnectionUser.Instance().CurrentUser != null)
            {
                if (result == UserRole.admin)
                {
                    AdminView viewNew = new AdminView();
                    this.Close();
                    viewNew.ShowDialog();
                }
                else if (result == UserRole.korisnik)
                {
                    RegularView viewNew = new RegularView();
                    this.Close();
                    viewNew.ShowDialog();
                }
                else
                {
                    return;
                }
            }
        }