コード例 #1
0
        public Task <Unit> Handle(AddAddressConferenceCommand message, CancellationToken cancellationToken)
        {
            var address = new Address(message.Id, message.Address1, message.Address2, message.Address3,
                                      message.Number, message.Postcode, message.City, message.County, message.ConferenceId.Value);

            if (!address.IsValid())
            {
                NotifyValidationError(address.ValidationResult);
                return(Task.FromResult(Unit.Value));
            }

            var conference = _conferenceRepository.GetById(address.ConferenceId.Value);

            conference.SwitchToPresencial();

            _conferenceRepository.Update(conference);
            _conferenceRepository.AddAddress(address);

            if (Commit())
            {
                _mediator.PublishEvent(new AddressConferenceAddedEvent(address.Id, address.Address1, address.Address2, address.Address3,
                                                                       address.Number, address.Postcode, address.City, address.County, address.ConferenceId.Value));
            }

            return(Task.FromResult(Unit.Value));
        }