/// <summary> /// Save the preferences object and invoke the required event handlers. /// </summary> public void Save() { OnPreSave?.Invoke(this, Preferences); Save(PrefPath, Preferences); OnSave?.Invoke(this, Preferences); OnUpdate?.Invoke(this, Preferences); }
public bool Update(Dto model) { bool toReturn = false; var entity = MapDtoToEntity(model); var command = SQLiteUtils.UpdateCommand <Entity>(tableName, entity); OnPreSave?.Invoke(new OnPreSaveArgs <Dto>(model)); var connection = new SQLiteConnection(_connectionString); try { connection.Open(); command.Connection = connection; command.ExecuteNonQuery(); } catch (Exception ex) { toReturn = false; OnError?.Invoke(new OnErrorArgs <Dto>(model, ex, OnErrorType.Update)); } finally { connection.Clone(); OnPostSave?.Invoke(new OnPostSaveArgs <Dto>(model, toReturn)); } return(toReturn); }