I'm having a difficult time getting the Saved event from the BusinessBase to fire (or capture it anyway)
I have a Customer object with the Save method overridden
public override Customer Save(){
if (IsDeleted && !CanDeleteObject()) throw new System.Security.SecurityException("User not authorized to remove a Customer"); else if (IsNew && !CanAddObject()) throw new System.Security.SecurityException("User not authorized to add a Customer"); else if (!CanEditObject()) throw new System.Security.SecurityException("User not authorized to update a Customer"); return base.Save();}
In my form I wire up the event like this
_customer.Saved +=
new EventHandler<Csla.Core.SavedEventArgs>(_customer_Saved); void _customer_Saved(object sender, Csla.Core.SavedEventArgs e) { throw new Exception("The method or operation is not implemented.");}
When I make changes to the customer and save, it saves fine, but does not call the _customer_Saved method.
Am I doing anything wrong here?
Ok, I found my problem. I was following the recommended save routing in the book.
Customer temp = _customer.Clone();temp.ApplyEdit();
try {_customer = temp.Save();
_customer.BeginEdit();
So I'm actually calling the save on the clone which hasn't been wired up. So now I just need to figure the best way to wire the save event up in some usercontrols on the form that also have the customer object passed to them.
Curelom:Ok, I found my problem. I was following the recommended save routing in the book.
Copyright (c) Marimer LLC