예제 #1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                User user = (User)lstUsers.SelectedItem;

                MessageBoxResult result = MessageBox.Show(
                    string.Format(Localization.Language.ConfirmDeletetingUserX, user.FullName), Localization.Language.ConfirmDeleteting,
                    MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

                if (result == MessageBoxResult.Yes)
                {
                    if (user.Id != Guid.Empty)
                    {
                        if (UserManagement.ArchiveUser(user) > 0)
                        {
                            ((ObservableCollection <User>)lstUsers.DataContext).Remove(user);
                        }
                    }
                    else // When not yet saved will be deleted ie. Id = Guid.Empty
                    {
                        ((ObservableCollection <User>)lstUsers.DataContext).Remove(user);
                    }

                    lbMessages.Content = string.Format(Localization.Language.UserXIsDeleted, user.FullName);
                }
            }
            catch (Exception ex)
            {
                lbMessages.Content = ex.Message;
            }
        }