jeudi 29 avril 2021

Can I have a nested OR statement within my Ternary If statement?

I am wondering if it is possible to turn this statement of code into a ternary if statement.

var placeHolder = await Source.EntityOrDefaultAsync<_Item>(item => item.CompanyID == order.CompanyID && item.ItemID == od.ItemID);

                if (placeHolder.TaxedAllCountryRegions = true || placeHolder.TaxedFed == 1 && placeHolder.TaxedState == 1)
                {
                    decimal.TryParse(placeHolder.HandlingFee, out decimal trueFee);
                    od.HandlingFee = trueFee * od.Quantity;
                }

I tried formatting it like this- but don't think it quite works.

 var placeHolder = await Source.EntityOrDefaultAsync<_Item>(item => item.CompanyID == order.CompanyID && item.ItemID == od.ItemID);

                return (placeHolder.TaxedAllCountryRegions = true || placeHolder.TaxedFed == 1 && placeHolder.TaxedState == 1) ?
                                                                                                                                decimal.TryParse(placeHolder.HandlingFee, out decimal trueFee)
                                                                                                                                : false;
                od.HandlingFee = trueFee * od.Quantity;

Aucun commentaire:

Enregistrer un commentaire