private void OnAddConfigClick(object sender, RoutedEventArgs e) { if (m_pageViewModel.Key == string.Empty || m_pageViewModel.Value == string.Empty) { RadMessageBox.Show(AppCommonResource.KeyValueNotEmpty); return; } if (DbHelper.Instance.CheckExistConfig(m_pageViewModel.Key)) { RadMessageBox.Show(AppCommonResource.ConfigExisted); return; } var config = new B1B2ConfigValue() { Key = m_pageViewModel.Key, Value = m_pageViewModel.Value }; DbHelper.Instance.AddB1B2Config(config); m_pageViewModel.ItemsSource.Add(config); m_pageViewModel.Key = string.Empty; m_pageViewModel.Value = string.Empty; }
public void DeleteB1B2Config(B1B2ConfigValue configValue) { using (var context = new EnglishQuestionContext()) { context.Entry(configValue).State = EntityState.Deleted; context.SaveChanges(); } }
public void AddB1B2Config(B1B2ConfigValue configValue) { using (var context = new EnglishQuestionContext()) { context.B1B2ConfigValues.Add(configValue); context.SaveChanges(); } }