private async Task UpdateLabelAsync(LabelModel label) { string updateQuery = $"update {_tableName} set title = '{label.Title}', color='{label.Color}' where id = '{label.Id}';"; int res = await _connection.ExecuteAsync(updateQuery); if (res <= 0) { throw new DatabaseException("Update label failed"); } }
private async Task CreateLabelAsync(LabelModel newLabel) { string insertQuery = $"insert into {_tableName} (id, title, color) " + $"values('{newLabel.Id}', '{newLabel.Title}', '{newLabel.Color}');"; int res = await _connection.ExecuteAsync(insertQuery); if (res <= 0) { throw new DatabaseException("Create label failed"); } }
public async Task CreateOrUpdateLabelAsync(LabelModel label) { var existingLabel = await GetModelByIdAsync <LabelModel>(label.Id); if (existingLabel == null) { await CreateLabelAsync(label); } else { await UpdateLabelAsync(label); } }