bool IHost.Delete(Theme theme) { if (KryptonMessageBox.Show(this, Strings.QuestionDeleteTheme, Strings.DeleteTheme, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Account user = SelectUserDialog.Get(this); if (user == null) { return(false); } using (ISession session = DataHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.Delete(theme); transaction.Commit(); return(true); } catch (ADOException e) { transaction.Rollback(); Trace.TraceError(ErrorHelper.Message(e)); ErrorHelper.ShowDbError(this, e); return(false); } } } } return(false); }
bool IHost.Open(Theme theme) { user = SelectUserDialog.Get(this); if (user != null) { currentTheme = theme; Text = $"{Strings.VocabularyTest} - {theme.Name}"; LoadWindowLayout(); addons.Run(); using (ISession session = DataHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { currentTheme.AccessDate = DateTime.Now; session.SaveOrUpdate(currentTheme); transaction.Commit(); backgroundLoading.RunWorkerAsync(new DictionaryProperty(dictionaries, theme.Languages.ToList())); return(true); } catch (ADOException e) { transaction.Rollback(); Trace.TraceError(ErrorHelper.Message(e)); ErrorHelper.ShowDbError(this, e); return(false); } } } } return(false); }
bool IHost.Create() { currentTheme = ThemeDialog.Create(this); if (currentTheme != null) { user = SelectUserDialog.Get(this); if (user != null) { Text = $"{Strings.VocabularyTest} - {currentTheme.Name}"; LoadWindowLayout(); addons.Run(); return(true); } } return(false); }