server things
This commit is contained in:
@@ -35,50 +35,42 @@ class DBHelper {
|
||||
'CREATE TABLE templates (ID INTEGER PRIMARY KEY AUTOINCREMENT, CID TEXT, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr TEXT, KontDat DATE, Betreuung TEXT, AbbauDat DATE, Auftrag TEXT, KontAbsp TEXT, SonstBem TEXT, FKontakt1 TEXT, FKontakt2 TEXT, FKontakt3 TEXT, KTage1 INTEGER, KTage2 INTEGER, ProtoAm DATE, IntKomm TEXT, DECLNG DECIMALS(4,8), DECLAT DECIMALS(4,8))');
|
||||
}
|
||||
|
||||
// Function to add a finished entrie
|
||||
Future<void> addPlace(Map<String, dynamic> place) async {
|
||||
// Function to add a finished entry and return its ID
|
||||
Future<int> addPlace(Map<String, dynamic> place) async {
|
||||
var placeDBClient = await placeDB;
|
||||
|
||||
// gets an camid if it already exists
|
||||
final existingID = await placeDBClient.query(
|
||||
'place',
|
||||
where: 'ID = ?',
|
||||
whereArgs: [place['ID']],
|
||||
);
|
||||
|
||||
// checks if the camid var from before is empty to avoid double entries
|
||||
if (existingID.isNotEmpty) {
|
||||
updatePlace(place);
|
||||
return;
|
||||
return existingID.first['ID'] as int; // Return existing ID
|
||||
}
|
||||
|
||||
// inserts the entrie in the database
|
||||
await placeDBClient.insert(
|
||||
int id = await placeDBClient.insert(
|
||||
'place',
|
||||
place,
|
||||
|
||||
// replaces the entrie with the new onw if a unique value exists and conflicts
|
||||
// conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
//conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
|
||||
return id; // Return the ID of the newly inserted entry
|
||||
}
|
||||
|
||||
Future<void> updatePlace(Map<String, dynamic> place) async {
|
||||
var placeDBClient = await placeDB;
|
||||
|
||||
await placeDBClient.update(
|
||||
'place',
|
||||
place,
|
||||
where: "ID = ?",
|
||||
whereArgs: [place['ID']]
|
||||
);
|
||||
await placeDBClient
|
||||
.update('place', place, where: "ID = ?", whereArgs: [place['ID']]);
|
||||
}
|
||||
|
||||
// function to update the sent value
|
||||
Future<void> updateSent() async {
|
||||
Future<void> updateSent(int id) async {
|
||||
var placeDBClient = await placeDB;
|
||||
|
||||
placeDBClient.update('place', true as Map<String, Object?>,
|
||||
where: 'ID = ?', whereArgs: ['ID']);
|
||||
await placeDBClient.update('place', {'Sent': 1},
|
||||
where: 'ID = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
// same thing as before but with templatews
|
||||
|
||||
Reference in New Issue
Block a user