Files
fforte/lib/screens/sharedMethods/save_main_entry.dart
Nico ecafe2df02 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
2025-05-12 18:18:36 +02:00

39 lines
1.0 KiB
Dart

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,
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
if (entryData["ID"] == "") {
entryData.remove("ID");
entryId = await placeDB!.addMainEntry(entryData);
} else {
entryId = await placeDB!.updateMainEntry(entryData);
}
if (sent == true) {
placeDB.updateSent(entryId); // Update 'Sent' using the correct ID
}
await placeDB.deleteTemplateById(entryData["CID"]!);
}
}