public override void Delete() { if (CurrentUserViewModel == null) { ModernDialog.ShowMessage("请选择一个用户。", "操作警告", MessageBoxButton.OK); return; } if (ModernDialog.ShowMessage("确定删除当前用户?", "删除警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (_userDataAccessor.Delete(Mapper.Map <User>(CurrentUserViewModel))) { var currentIndex = UserViewModels.IndexOf(CurrentUserViewModel); UserViewModels.Remove(CurrentUserViewModel); if (currentIndex > 0) { CurrentUserViewModel = UserViewModels[currentIndex - 1]; } else if (UserViewModels.Count > 0) { CurrentUserViewModel = UserViewModels[0]; } } } }
private void UpdateUserAuthentication() { try { if (SelectedUserViewModel == null) { Messenger.Default.Send(new NotificationMessage("请先选择人员!"), Tokens.UserPage_ShowNotification); return; } var coreModel = _userRepo.GetByKey(SelectedUserViewModel.UserID); var viewModel = new UserAuthMngtViewModel(coreModel); Messenger.Default.Send(new OpenWindowMessage() { DataContext = viewModel, WindowType = "UserAuthenticationView", }, Tokens.OpenUserView); if (viewModel.ViewModelAttachment.LastOperationSuccess) { var index = UserViewModels.IndexOf(SelectedUserViewModel); UserViewModels[index] = new UserViewModel(viewModel.ViewModelAttachment.CoreModel); var coreUser = CurrentDepartmentUsers.FirstOrDefault(x => x.UserID == coreModel.UserID); CurrentDepartmentUsers.Remove(coreUser); CurrentDepartmentUsers.Add(viewModel.ViewModelAttachment.CoreModel); } } catch (Exception ex) { Log.Error(ex); } }