private void ModifyTimeGroup() { try { if (SelectedTimeGroupViewModel == null) { Messenger.Default.Send(new NotificationMessage("请先选择时间组!"), Tokens.TimeGroupPage_ShowNotification); return; } var viewModel = new TimeGroupViewModel(SelectedTimeGroupViewModel.CurrentTimeGroup); Messenger.Default.Send(new OpenWindowMessage() { DataContext = viewModel }, Tokens.OpenTimeGroupView); if (viewModel.ViewModelAttachment.LastOperationSuccess) { var index = TimeGroupViewModels.IndexOf(SelectedTimeGroupViewModel); TimeGroupViewModels[index] = viewModel; } } catch (Exception ex) { Log.Error(ex); } }
private void AddTimeGroup() { try { var timeGroupViewModel = new TimeGroupViewModel(new TimeGroup()); Messenger.Default.Send(new OpenWindowMessage() { DataContext = timeGroupViewModel }, Tokens.OpenTimeGroupView); if (timeGroupViewModel.ViewModelAttachment.LastOperationSuccess) { TimeGroupViewModels.Add(new TimeGroupViewModel(timeGroupViewModel.ViewModelAttachment.CoreModel)); } } catch (Exception ex) { Log.Error(ex); } }