コード例 #1
0
        public async Task Handle(RemoveProtectionAreaCommand notification, CancellationToken cancellationToken)
        {
            if (!notification.IsValid())
            {
                NotifyValidationErrors(notification);
                return;
            }

            if (await _superheroRepository.GetByProtectionArea(notification.Id) != null)
            {
                await _bus.RaiseEvent(new DomainNotification(notification.MessageType, "Unable to remove the protection area, it is used by one or more superheroes"));

                return;
            }

            _protectionAreaRepository.Remove(notification.Id);

            await CommitAsync();
        }
コード例 #2
0
 public async Task Remove(Guid id)
 {
     var removeCommand = new RemoveProtectionAreaCommand(id);
     await _bus.SendCommand(removeCommand);
 }