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(); }
public async Task Remove(Guid id) { var removeCommand = new RemoveProtectionAreaCommand(id); await _bus.SendCommand(removeCommand); }