void RegisterCommandExecute()
        {
            var myUser = new User()
            {
                FirstName = FirstName,
                LastName  = LastName,
                Email     = Email,
                Login     = Login,
                Password  = SHA1Helper.GetSHA1HashData(Password)
            };
            // Call the service method to insert an user
            var err_code = _client.InsertUser(myUser);

            if (err_code == 0)
            {
                // After adding the user, call the service to log the user and get his id
                myUser.IdUser = _client.LogUser(myUser);
                if (myUser.IdUser != 0)
                {
                    // Get the current window to close it after launching the main window
                    var parentWindow = Application.Current.Windows.Cast <Window>().SingleOrDefault(x => x.IsActive);
                    new MainWindow()
                    {
                        DataContext = new MainWindowViewModel(myUser)
                    }.Show();
                    parentWindow.Close();
                }
            }
            else
            {
                MyMessageBox.ErrorMessageBox(err_code);
            }
        }
 void UpdateProfileCommandExecute()
 {
     User.FirstName = FirstNameTextBox;
     User.LastName  = LastNameTextBox;
     User.Email     = EmailTextBox;
     User.Login     = LoginTextBox;
     User.Password  = SHA1Helper.GetSHA1HashData(PasswordTextBox);
     MyMessageBox.ErrorMessageBox(_client.UpdateUser(User));
 }
Exemple #3
0
 public LoginWindowViewModel()
 {
     try
     {
         _client = new Service1Client();
     }
     catch
     {
         MyMessageBox.ErrorMessageBox(ErrorHelper.ERR_200.code);
     }
 }
        void SeekTickerCommandExecute(string param)
        {
            // Message for current operation in the bottom of the window
            string operation_title = "Current Operation: ";

            TreatmentsLabel = operation_title + "Adding the company with " + param.ToUpper() + " ticker into the database.";
            Company company = new Company();

            company.Ticker = param.ToUpper();
            MyMessageBox.ErrorMessageBox(_client.InsertCompany(user.IdUser, company));
            TreatmentsLabel = "";
            DisplayCompanies();
        }
        void DeleteProfileCommandExecute()
        {
            var result = MessageBox.Show(
                "You are going to delete your profile.\n\nAre you sure you want to continue ?",
                "Warning",
                MessageBoxButton.YesNo,
                MessageBoxImage.Warning
                );

            if (result == MessageBoxResult.Yes)
            {
                MyMessageBox.ErrorMessageBox(_client.DeleteUserById(User.IdUser));
                Application.Current.Shutdown();
            }
        }
        void DeleteCompanyCommandExecute()
        {
            var result = MessageBox.Show(
                "You are going to delete your the selected company.\n\nAre you sure you want to continue ?",
                "Warning",
                MessageBoxButton.YesNo,
                MessageBoxImage.Warning
                );

            if (result == MessageBoxResult.Yes)
            {
                MyMessageBox.ErrorMessageBox(_client.DeleteCompanyById(User.IdUser, SelectedCompanyId));
                DisplayCompanies();
            }
        }
Exemple #7
0
        void LogOnCommandExecute()
        {
            var myUser = new User()
            {
                Login    = Login,
                Password = SHA1Helper.GetSHA1HashData(Password)
            };

            myUser.IdUser = _client.LogUser(myUser);
            if (myUser.IdUser != 0)
            {
                // Get the current window to close it after opening main window
                var parentWindow = Application.Current.Windows.Cast <Window>().SingleOrDefault(x => x.IsActive);
                new MainWindow
                {
                    DataContext = new MainWindowViewModel(_client.SelectUserById(myUser.IdUser))
                }.Show();
                parentWindow.Close();
            }
            else
            {
                MyMessageBox.ErrorMessageBox(ErrorHelper.ERR_200.code);
            }
        }