public async Task <bool> HideLocalOperation(string opId, bool isHidden) { LoggingService.Trace("Querying OperationsDatabase.HideLocalOperation"); var databaseConnection = await GetDatabaseConnection <OperationDatabaseModel>().ConfigureAwait(false); var dbLock = databaseConnection.GetConnection().Lock(); try { var operationModel = await GetOperationModel(opId); if (operationModel == null) { return(false); } operationModel.IsHiddenLocally = isHidden; var dbModel = OperationDatabaseModel.ToOperationDatabaseModel(operationModel); databaseConnection.GetConnection().UpdateWithChildren(dbModel); return(true); } catch (Exception e) { LoggingService.Error(e, "Error Querying OperationsDatabase.HideLocalOperation"); return(false); } finally { dbLock.Dispose(); } }
public async Task <int> SaveOperationModel(OperationModel operationModel) { LoggingService.Trace("Querying OperationsDatabase.SaveOperationModel"); var databaseConnection = await GetDatabaseConnection <OperationDatabaseModel>().ConfigureAwait(false); var dbLock = databaseConnection.GetConnection().Lock(); try { var operationDatabaseModel = OperationDatabaseModel.ToOperationDatabaseModel(operationModel); var existingData = await GetOperationModel(operationModel.Id); if (existingData != null) { operationDatabaseModel.IsHiddenLocally = existingData.IsHiddenLocally; } databaseConnection.GetConnection().InsertOrReplaceWithChildren(operationDatabaseModel); return(0); } catch (Exception e) { LoggingService.Error(e, "Error Querying OperationsDatabase.SaveOperationModel"); return(1); } finally { dbLock.Dispose(); } }