Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • System Architecture

Search

Written by Oleksandr Sydorenko

Updated at May 5th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • System Architecture
+ More

You have to implement a search. However, since a lead’s contact information can be updated—first name, last name, and phone number—sales agents may not be aware of the changes applied by other agents and may want to locate leads using their con‐ tact information, including historical values. We can easily project the historical information:

public class LeadSearchModelProjection

{

public long LeadId { get; private set; }

public HashSet<string> FirstNames { get; private set; }

public HashSet<string> LastNames { get; private set; }

public HashSet<PhoneNumber> PhoneNumbers { get; private set; }

public int Version { get; private set; }

public void Apply(LeadInitialized @event)

{

LeadId = @event.LeadId;

FirstNames = new HashSet<string>(); LastNames = new HashSet<string>(); PhoneNumbers = new HashSet<PhoneNumber>();

FirstNames.Add(@event.FirstName); LastNames.Add(@event.LastName); PhoneNumbers.Add(@event.PhoneNumber);

Version = 0;

}

public void Apply(ContactDetailsChanged @event)

{

FirstNames.Add(@event.FirstName); LastNames.Add(@event.LastName); PhoneNumbers.Add(@event.PhoneNumber);

Version += 1;

}

public void Apply(Contacted @event)

{

Version += 1;

}

public void Apply(FollowupSet @event)

{

Version += 1;

}

public void Apply(OrderSubmitted @event)

{

Version += 1;

}

public void Apply(PaymentConfirmed @event)

{

Version += 1;

}

}

The projection logic uses the LeadInitialized and ContactDetailsChanged events to populate the respective sets of the lead’s personal details. Other events are ignored since they do not affect the specific model’s state.

Applying this projection logic to Casey Davis’s events from the earlier example will result in the following state:

LeadId: 12 FirstNames: ['Casey']

LastNames: ['David', 'Davis'] PhoneNumbers: ['555-2951', '555-8101']

Version: 6

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Discovering Domain Knowledge
  • Business Problems
  • Knowledge Discovery
  • Communication
  • What Is a Ubiquitous Language?

info@smartphonekey.com

  • Home
  • How It Works
  • Features
  • Residents and Tenants
  • Property Managers
  • Airbnb Hosts
  • Products
  • Blog
  • Guide for Usage and Installation
  • Our Team
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Facebook
  • Instagram
  • LinkedIn
© 2025, Smartphonekey.com Powered by Shopify
Expand