/// <summary> /// For testing /// </summary> /// <returns> /// The collection of all anonymous customers /// </returns> internal IEnumerable <IAnonymousCustomer> GetAllAnonymousCustomers() { using (var repository = RepositoryFactory.CreateAnonymousCustomerRepository(UowProvider.GetUnitOfWork())) { return(repository.GetAll()); } }
/// <summary> /// Gets an <see cref="ICustomer"/> or <see cref="IAnonymousCustomer"/> object by its 'UniqueId' /// </summary> /// <param name="entityKey">GUID key of either object to retrieve</param> /// <returns><see cref="ICustomerBase"/></returns> public ICustomerBase GetAnyByKey(Guid entityKey) { ICustomerBase customer; // try retrieving an anonymous customer first as in most situations this will be what is being queried using (var repository = _repositoryFactory.CreateAnonymousCustomerRepository(_uowProvider.GetUnitOfWork())) { customer = repository.Get(entityKey); } if (customer != null) { return(customer); } // try retrieving an existing customer using (var repository = _repositoryFactory.CreateCustomerRepository(_uowProvider.GetUnitOfWork())) { return(repository.Get(entityKey)); } }