update method
The update
method updates an existing entity.
Implementation
@override
FutureOr<void> update(
PgrServiceModel entity, {
bool createOpLog = true,
}) async {
return retryLocalCallOperation(() async {
final clientReferenceId = entity.clientReferenceId;
final serviceRequestId = entity.serviceRequestId;
if (serviceRequestId != null && clientReferenceId.isEmpty) {
await sql.batch((batch) async {
batch.update(
sql.pgrService,
PgrServiceCompanion(
applicationStatus: Value(entity.applicationStatus),
),
where: (tbl) => tbl.serviceRequestId.equals(serviceRequestId),
);
});
} else if (clientReferenceId.isNotEmpty && serviceRequestId != null) {
await sql.batch((batch) async {
batch.update(
sql.pgrService,
PgrServiceCompanion(
applicationStatus: Value(entity.applicationStatus),
serviceRequestId: Value(serviceRequestId),
),
where: (tbl) => tbl.clientReferenceId.equals(clientReferenceId),
);
});
}
await super.update(
entity,
createOpLog: createOpLog,
);
});
}