I ran the below code in both the windows xaf application and the Blazor Xaf application.

        [Action(
        Caption = "Administer",
        ConfirmationMessage = "Are you sure you would like to administer these medications ? ", AutoCommit = true)]
        public int Administer()
        {
            foreach (var item in EntryID.Entries)
            {
                if (item.Medication.Qty > 0 && item.Medication.Qty >= item.Qty)
                 {
                    int a = item.Medication.Qty;
                    int b = item.Qty;
                    int c = a - b;

                    item.Medication.Qty = c;
                }
            }
            return 0;

        } 

In the windows xaf application it calculates all the individual medication taking away the administered Qty away from the in-stock Qty and returns the new in-stock value for each. However in the blazor xaf application this doesn't work the same. It tends to add the column of all the administered Qty together then take off from each of the stock values.

So if I administer 2 x paracetamol and have a stock of 64 and I also administer 2 x imodium of which I have a stock of 10, the results I get in Windows version = 62 Paracetamol left in stock and 8 imodium left in stock. However, in blazor I end up with 60 Paracetamol and 6 Imodium after the same code is executed.

This code is in the Entry class. Would this be better in a view controller?

Any help would be appreciated.

1

There are 1 best solutions below

0
On

In this case I don't need to use the foreach statement.