The ChangeQuantity Method
We start by creating a new class method in the Cinema.UtilsOpens in a new tab class named ChangeQuantity that takes three arguments.
—Utils.ChangeQuantity—
Utils.ChangeQuantity
ClassMethod ChangeQuantity(
ItemNum As %Integer,
TicketType As %Integer,
NewQuantity As %Integer)
{
If $data(%session.Data("Order")) {
// Open the current order object
Set ord = ##class(Cinema.TicketOrder).%OpenId(%session.Data("Order"))
// Update quantity
Set itm=ord.Items.GetAt(ItemNum)
// ...
}
}
The code for ChangeQuantity starts by ensuring that we have an order to modify. If the session timed out, then “Order” will not be defined in the Session object and we can just quit.
Otherwise, we retrieve the correct TicketOrder object and then use the GetAt method to open the appropriate TicketItem object.