Ejemplo n.º 1
0
        public async Task <CreateContactResponse> Handle(CreateContactCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("CreateContactHandler - handle");

            await _validator.HandleValidation(request.ContactRequest);

            var requestedContact = request.ContactRequest;
            var contact          = new Domain.Contact(ContactType.Contact,
                                                      requestedContact.FirstName,
                                                      requestedContact.LastName,
                                                      requestedContact.Title,
                                                      requestedContact.Company,
                                                      requestedContact.Description,
                                                      null);

            var contactId = await _uow.Connection.InsertAsync <Guid, Domain.Contact>(contact);

            await _bus.Publish <ContactCreated>(new
            {
                FirstName     = "sss",
                CorrelationId = _correlationContextAccessor?.CorrelationContext?.CorrelationId
            });

            return(new CreateContactResponse
            {
                Contact = contact.ToContactProtobuf()
            });
        }
Ejemplo n.º 2
0
        public async Task <CreateContactResponse> Handle(CreateContactCommand request, CancellationToken cancellationToken)
        {
            await _validator.HandleValidation(request.ContactRequest);

            var requestedContact = request.ContactRequest;
            var contact          = new Domain.Contact(ContactType.Contact,
                                                      requestedContact.FirstName,
                                                      requestedContact.LastName,
                                                      requestedContact.Title,
                                                      requestedContact.Company,
                                                      requestedContact.Description,
                                                      null);

            var contactId = await _uow.Connection.InsertAsync <Guid, Domain.Contact>(contact);

            _eventBus.Publish(new ContactCreatedEvent()
            {
                Id = Guid.NewGuid()
            });

            return(new CreateContactResponse
            {
                Contact = contact.ToContactProtobuf()
            });
        }