예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_viewModel.CurrentUser == null)
                {
                    throw new ArgumentNullException(nameof(_viewModel.CurrentUser));
                }
                if (_viewModel.CurrentRole == null)
                {
                    throw new ArgumentNullException(nameof(_viewModel.CurrentRole));
                }

                var control = (Control)sender;
                if (control.Name == "CancelButton")
                {
                    DialogResult = false;
                }
                else
                {
                    _viewModel.CurrentRole.IsDirty = true;
                    _viewModel.CurrentUser.AddRole(_viewModel.CurrentRole);
                    DialogResult = true;
                }
            }
            catch (Exception ex)
            {
                _messageBoxFacade.ShowError(ex.Message);
            }
        }
예제 #2
0
        private void OkButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var parent = Parent as Window;
                if (parent == null)
                {
                    throw new InvalidOperationException("Could not get parent window of input control");
                }

                InputValue = InputTextBox.Text;
                if (string.IsNullOrEmpty(InputValue))
                {
                    throw new InvalidDataException("You must enter a value");
                }
                parent.DialogResult = true;
            }
            catch (Exception ex)
            {
                _messageBoxFacade.ShowError(ex);
            }
        }
예제 #3
0
        private async void CreateUserButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_viewModel.CurrentUser == null)
                {
                    throw new ArgumentNullException(nameof(_viewModel.CurrentUser));
                }
                if (_viewModel.NewUser == null)
                {
                    throw new ArgumentNullException(nameof(_viewModel.NewUser));
                }

                if (_viewModel.NewUser.Department == null)
                {
                    throw new ArgumentNullException("department");
                }
                if (string.IsNullOrEmpty(_viewModel.NewUser.Name))
                {
                    throw new ArgumentNullException("name");
                }
                if (string.IsNullOrEmpty(_viewModel.NewUser.Email))
                {
                    throw new ArgumentNullException("email");
                }
                if (_viewModel.NewUser.DateHired < Extensions.GetEpochStartTime)
                {
                    throw new ArgumentException("Hire date must be after Jan 1, 1970");
                }
                if (!_messageBoxFacade.Confirm(confirmMessage))
                {
                    return;
                }

                IsEnabled = false;
                //await Task.Run(() => makeCall);
                DialogResult = true;
            }
            catch (Exception ex)
            {
                _messageBoxFacade.ShowError(ex.Message);
            }
            finally
            {
                IsEnabled = true;
            }
        }
예제 #4
0
 private void BrowseButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var dialog       = new OpenFileDialog();
         var dialogResult = dialog.ShowDialog() ?? false;
         if (!dialogResult)
         {
             return;
         }
         _viewModel.InputText = dialog.FileName;
     }
     catch (Exception ex)
     {
         _messageBox.ShowError(ex);
     }
 }
예제 #5
0
        private void DeleteUserButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_viewModel.CurrentUser == null)
                {
                    throw new ArgumentNullException(nameof(_viewModel.CurrentUser));
                }

                if (!_messageBoxFacade.Confirm(deleteConfirmation))
                {
                    return;
                }
                //doDelete
                _viewModel.CurrentUser = null;
            }
            catch (Exception ex)
            {
                _messageBoxFacade.ShowError(ex.Message);
            }
        }
예제 #6
0
 private void OnKeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         var control = (Control)sender;
         if (control.Name == "FilterBox")
         {
             UpdateFilter();
         }
         else if (control.Name == "MainComponent" && Keyboard.IsKeyDown(Key.LeftCtrl) && e.Key == Key.U)
         {
             var adminViewModel = new AdminViewModel {
                 CurrentUser = _viewModel.CurrentUser
             };
             var adminWindow = _kernel.Get <AdminWindow>(new ConstructorArgument("viewModel", adminViewModel));
             adminWindow.Owner         = this;
             adminWindow.ShowInTaskbar = false;
             if (!adminWindow.ShowDialog().Value)
             {
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         _messageBoxFacade.ShowError(ex);
     }
 }