private void ModifyDeviceController() { try { if (SelectedDeviceRoleViewModel == null) { Messenger.Default.Send(new NotificationMessage("请先选择设备角色!"), Tokens.DeviceRolePage_ShowNotification); return; } var viewModel = new DeviceRoleViewModel(SelectedDeviceRoleViewModel.CurrentDeviceRole); Messenger.Default.Send(new OpenWindowMessage() { DataContext = viewModel }, Tokens.OpenDeviceRoleView); if (viewModel.ViewModelAttachment.LastOperationSuccess) { var index = DeviceRoleViewModels.IndexOf(SelectedDeviceRoleViewModel); DeviceRoleViewModels[index] = new DeviceRoleViewModel(viewModel.ViewModelAttachment.CoreModel); } } catch (Exception ex) { Log.Error(ex); } }
private void AddDeviceController() { try { var viewModel = new DeviceRoleViewModel(new DeviceRole()); Messenger.Default.Send(new OpenWindowMessage() { DataContext = viewModel }, Tokens.OpenDeviceRoleView); if (viewModel.ViewModelAttachment.LastOperationSuccess) { DeviceRoleViewModels.Add(viewModel); } } catch (Exception ex) { Log.Error(ex); } }
private void ConfirmDeviceRole() { DispatcherHelper.CheckBeginInvokeOnUI(() => { string message = ""; try { _deviceRoleRepo.Delete(SelectedDeviceRoleViewModel.CurrentDeviceRole.DeviceRoleID); message = "删除设备角色成功!"; DeviceRoleViewModels.Remove(SelectedDeviceRoleViewModel); } catch (Exception ex) { Log.Error(ex); message = "删除设备角色失败!"; } Messenger.Default.Send(new NotificationMessage(message), Tokens.DeviceRolePage_ShowNotification); }); }