auto PostgresInstructorSe rverService createTrip DataSource Id a_stude

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
auto PostgresInstructorServerService::createTrip(DataSource::Id a_studentId, time_t startTime) -> bool
{
try
{
auto l_transaction(this->m_session.beginTransaction(Transaction::IsolationLevel::Serializable));
auto const l_createdTripId = (DWord) this->m_session.createQuery(LR"(
insert into "Trips"
("studentId", "beginDate") values (?, ?)
returning "id"
)")
.bind(1, a_studentId)
.bind(2, ctime (&startTime))
.getUniqueResult()[1];
l_transaction.commit();
return true;
}
catch (const NoResultException& exception)
{
// TODO: Log exception msg
return false;
}
}