7.2 Return Values from a Method

7.2 Return Values from a Method

  
At 4:28, the cut and paste is so quick. I need a second set of eyes to spot the copy and paste is between the Interface -> Purchase_Show -> AddProduct and Logic -> AddPurchasedProduct...
Couldn't we have also used condition validation methods from previous lessons (Like we did on the product details save action.) to prevent the negative result? Which is more ideal in this situation?
Braxton Bragg wrote:
Couldn't we have also used condition validation methods from previous lessons (Like we did on the product details save action.) to prevent the negative result? Which is more ideal in this situation?
 
Hi Braxton,

Yes you could do this validation inside the screen action. What you gain with user actions is reusability. You can now use this action anywhere in your application, keeping only one place to maintain that logic.
You will see later on that you can even use this action in other applications (module 15) or even in other systems (exposing this action thru a webservice).
There is a business error in this sample, 
the addneworder item called both when adding or updating an order item ...
but the logic for stock validation and stock update both are writen for the case of adding an item :

when an existing order line has 2 items ,and is changed to 3 , stock should be deducted by 1 not by three ( deduct stock by (updatedorderitem.quantity - originalorderitem.quanty ) instead of deducting  by updatedorderitem.quantity