public async Task Handle(RemoveSuperheroCommand notification, CancellationToken cancellationToken) { if (!notification.IsValid()) { NotifyValidationErrors(notification); return; } _superheroRepository.Remove(notification.Id); if (await CommitAsync()) { var superheroEvent = new SuperheroRemovedEvent(notification.Id); await _bus.RaiseEvent(superheroEvent); await _auditEventService.Subscribe(new AuditEvent( Guid.NewGuid(), nameof(Superhero), notification.Id, notification.Username, AuditEventAction.Remove )); } }
public async Task Handle(SuperheroRemovedEvent notification, CancellationToken cancellationToken) { await _cacheManager.RemoveAsync($"superheroGetAsync_{notification.Id}"); }