Open africaninternetgroup opened 8 years ago
Generally you'd want to call BusinessRules.CheckRules
at the bottom of your DataPortal_Fetch
or Child_Fetch
method (or both).
Keep in mind that CheckRules
checks the rules for an object, not for the entire graph.
Thanks for your quick response
I have a business object called the taxpaysliplineitem which calculates the tax payable by a employee on his income. when the object is created the it calculates the correct amount of tax. When I save the object and retrieve it from the data base the business rules are not being run and the amount of tax is zero. Below is the code I am using .I am trying to invoke the Business rules manually in the Child_OnDataPortalInvokeComplete when I retrieve the object from the database, Where I am I going wrong.
protected override void AddBusinessRules() { base.AddBusinessRules(); BusinessRules.AddRule(new TaxableIncomeYTDCalculator(TaxableIncomeYTDProperty) { Priority = 0 }); BusinessRules.AddRule(new TaxPeriodDeterminer(TaxPeriodProperty) { Priority = 1 }); BusinessRules.AddRule(new TaxPayableCalculator(TaxPayableProperty) { Priority = 2 }); BusinessRules.AddRule(new TaxDueCalculator(AmountProperty) { Priority = 3 });
private void Child_Fetch(TaxPayslipLineItemDto item,PayslipLineItems parent) { SetParent(Parent); using(BypassPropertyChecks) { Id = item.TaxId; Name = item.Name; TaxableIncomeBFWD = item.TaxableIncomeBFWD; TaxPaidBFWD = item.TaxPaidBFWD; TaxCredit = item.TaxCredit; TimeStamp = item.LastChanged; } TaxBands = TaxBandList.GetTaxBandList(Id);