| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | 
							- using System;
 
- using System.Linq;
 
- using InABox.Clients;
 
- using InABox.Core;
 
- namespace Comal.Classes
 
- {
 
-     public class ContactLookups : EntityLookup<Contact>, ILookupDefinition<Contact, Quote>
 
-     {
 
-         public Filter<Contact> DefineFilter(Quote[] items)
 
-         {
 
-             if (items == null || !items.Any())
 
-                 return new Filter<Contact>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
 
-             var customer = items.First().Customer;
 
-             if (!customer.IsValid())
 
-                 return new Filter<Contact>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
 
-             var contacts = new Client<CustomerContact>().Query(
 
-                 new Filter<CustomerContact>(x => x.Customer.ID).IsEqualTo(customer.ID),
 
-                 new Columns<CustomerContact>(x => x.Contact.ID)
 
-             );
 
-             var ids = contacts.Rows.Select(x => x.Get<CustomerContact, Guid>(c => c.Contact.ID));
 
-             if (!ids.Any())
 
-                 return new Filter<Contact>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
 
-             return new Filter<Contact>(x => x.ID).InList(ids.ToArray());
 
-         }
 
-         public override Columns<Contact> DefineColumns()
 
-         {
 
-             return new Columns<Contact>(
 
-                 x => x.ID,
 
-                 x => x.Name,
 
-                 x => x.Email
 
-             );
 
-         }
 
-         public override Filter<Contact> DefineFilter()
 
-         {
 
-             return null;
 
-         }
 
-         public override SortOrder<Contact> DefineSortOrder()
 
-         {
 
-             return new SortOrder<Contact>(x => x.Name);
 
-         }
 
-     }
 
- }
 
 
  |