public static async Task <bool> MoveAsync(Authentication authentication, IUserDescriptor descriptor) { var dialog = await MoveUserViewModel.CreateInstanceAsync(authentication, descriptor); if (dialog != null && await dialog.ShowDialogAsync() == true) { return(true); } return(false); }
private void MoveUser() { try { if (SelectedUserViewModel == null) { Messenger.Default.Send(new NotificationMessage("请先选择人员!"), Tokens.UserPage_ShowNotification); return; } var coreModel = _userRepo.GetByKey(SelectedUserViewModel.UserID); var viewModel = new MoveUserViewModel(coreModel); Messenger.Default.Send(new OpenWindowMessage() { DataContext = viewModel, WindowType = "MoveUserView", }, Tokens.OpenUserView); if (viewModel.ViewModelAttachment.LastOperationSuccess) { if (viewModel.ViewModelAttachment.CoreModel.DepartmentID != SelectedDepartmentId) { UserViewModels.Remove(SelectedUserViewModel); var coreUser = CurrentDepartmentUsers.FirstOrDefault(x => x.UserID == coreModel.UserID); CurrentDepartmentUsers.Remove(coreUser); } else { 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); } }
public static async Task <bool> MoveAsync(Authentication authentication, IUserDescriptor descriptor) { var dialog = await MoveUserViewModel.CreateInstanceAsync(authentication, descriptor); return(dialog?.ShowDialog() == true); }