コード例 #1
0
ファイル: PersonAggregate.cs プロジェクト: jezzsantos/clinics
        protected override void OnStateChanged(IChangeEvent @event)
        {
            switch (@event)
            {
            case Events.Person.Created _:
                break;

            case Events.Person.NameChanged changed:
                Name        = new PersonName(changed.FirstName, changed.LastName);
                DisplayName = new PersonDisplayName(changed.FirstName);
                Logger.LogDebug("Person {Id} changed name to {FirstName}, {LastName}", Id, changed.FirstName,
                                changed.LastName);
                break;

            case Events.Person.DisplayNameChanged changed:
                DisplayName = new PersonDisplayName(changed.DisplayName);
                Logger.LogDebug("Person {Id} changed display name to {DisplayName}", Id, changed.DisplayName);
                break;

            case Events.Person.EmailChanged changed:
                Email = new Email(changed.EmailAddress);
                Logger.LogDebug("Person {Id} changed email to {EmailAddress}", Id, changed.EmailAddress);
                break;

            case Events.Person.PhoneNumberChanged changed:
                Phone = new PhoneNumber(changed.PhoneNumber);
                Logger.LogDebug("Person {Id} changed phone number to {PhoneNumber}", Id, changed.PhoneNumber);
                break;

            default:
                throw new InvalidOperationException($"Unknown event {@event.GetType()}");
            }
        }
コード例 #2
0
 public static DisplayNameChanged Create(Identifier id, PersonDisplayName name)
 {
     return(new DisplayNameChanged
     {
         EntityId = id,
         DisplayName = name,
         ModifiedUtc = DateTime.UtcNow
     });
 }
コード例 #3
0
ファイル: PersonAggregate.cs プロジェクト: jezzsantos/clinics
 public void SetDisplayName(PersonDisplayName name)
 {
     RaiseChangeEvent(PersonsDomain.Events.Person.DisplayNameChanged.Create(Id, name));
 }