In your #2, when you say "close it after you select the customer", you mean discard the read-only list?
You don't necessarily need to do that. You can keep the read-only list in memory on the client - perhaps in a static cache field. Basically in a global cache.
If you that, you can have CustomerEdit tell the read-only CustomerList that a customer has changed, and CustomerList can update the changed CustomerInfo. The only trick to this is that a ReadOnlyBase object won't normally raise PropertyChanged events, so if you are maintaining a bound form against this read-only list then you'll need to add an INotifyPropertyChanged implementation to your CustomerInfo class.
But basically do something like this:
public class CustomerList : ReadOnlyListBase
{
private static CustomerList _cache;
public void ClearCache()
{
_cache = null;
}public static CustomerList GetList()
{
if (_cache == null)
_cache = DataPortal.Fetch<CustomerList>();
return _cache;
}internal static void CustomerSaved(CustomerEdit cust)
{
if (_cache != null)
{
var info = this.SingleOrDefault(c => c.Id == cust.Id);
if (info != null)
info.CustomerSaved(cust);
}
}
}public class CustomerInfo : ReadOnlyBase
{
internal void CustomerSaved(CustomerEdit cust)
{
// refresh property values from cust
// and maybe add OnPropertyChanged() to
// refresh bindings in the UI
}
}public class CustomerEdit : BusinessBase
{
public override CustomerEdit Save()
{
var result = base.Save();
CustomerList.CustomerSaved(result);
return result;
}
}
Copyright (c) Marimer LLC