コード例 #1
0
    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);
        }
    }
コード例 #2
0
    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);
        }
    }