The CompleteOrder Method
The CompleteOrder method has two tasks: to mark the TicketOrder object as complete and to update the TicketsSold property of the film. (Remember, we use the TicketsSold values to determine which films are most popular.)
To update TicketsSold, we retrieve each TicketItem object, get the associated Film object, and then add to TicketsSold the number of adult tickets and child tickets from the order.
—Utils.CompleteOrder—
Utils.CompleteOrder
ClassMethod CompleteOrder()
{
If $data(%session.Data("Order")) {
// Open the current order object
Set ord = ##class(Cinema.TicketOrder).%OpenId(%session.Data("Order"))
// Update the number of tickets sold for each film in the order
For i = 1:1:ord.Items.Count() {
Set itm = ord.Items.GetAt(i)
Set flm = itm.Show.Film
Set flm.TicketsSold = flm.TicketsSold +
itm.AdultTickets + itm.ChildTickets
// ...
}
}
}