public void Update(Guid id, string name, DateTime dateOfBirth) { var pet = _pets.FirstOrDefault(p => p.Id == id); pet.SetName(PetName.Create(name)); pet.SetDateOfBirth(PetDateOfBirth.Create(dateOfBirth)); foreach (var domainEvent in pet.DomainEvents) { _messageBroker.Publish(domainEvent); } }
public void Create(Guid id, string name, DateTime dateOfBirth) { var pet = new Pet(PetId.Create(id)); pet.SetName(PetName.Create(name)); pet.SetDateOfBirth(PetDateOfBirth.Create(dateOfBirth)); _pets.Add(pet); foreach (var domainEvent in pet.DomainEvents) { _messageBroker.Publish(domainEvent); } }