added sent and id column again for add_cam_main

id checks if entry already exists. sent says if the entry is already
sent to the db
This commit is contained in:
Nico
2025-05-12 18:18:36 +02:00
parent a5769a7dc0
commit ecafe2df02
7 changed files with 518 additions and 607 deletions

View File

@@ -1,21 +1,38 @@
import 'package:fforte/enums/databases.dart';
import 'package:fforte/interfaces/i_db.dart';
import 'package:fforte/methods/excursion_db_helper.dart';
import 'package:fforte/methods/place_db_helper.dart';
class SaveMainEntryMethod {
static void saveEntry(
{required Map<String, String> entryData,
required bool isTemplate,
bool sent = false}) async {
var placeDB = PlaceDBHelper();
static void saveEntry({
required Map<String, String> entryData,
required bool isTemplate,
required DatabasesEnum dbType,
bool sent = false,
}) async {
IDb? placeDB;
if (dbType == DatabasesEnum.place) {
placeDB = PlaceDBHelper();
} else if (dbType == DatabasesEnum.excursion) {
placeDB = ExcursionDBHelper();
}
int entryId;
// Get the ID of the newly added or updated place
int newPlaceId = await placeDB.addMainEntry(entryData);
if (entryData["ID"] == "") {
entryData.remove("ID");
entryId = await placeDB!.addMainEntry(entryData);
} else {
entryId = await placeDB!.updateMainEntry(entryData);
}
if (sent == true) {
placeDB.updateSent(newPlaceId); // Update 'Sent' using the correct ID
placeDB.updateSent(entryId); // Update 'Sent' using the correct ID
}
if (isTemplate) {
await placeDB.deleteTemplateById(entryData["CID"]!);
}
await placeDB.deleteTemplateById(entryData["CID"]!);
}
}