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 Remove(Guid id) { var username = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value; var removeCommand = new RemoveSuperheroCommand(id, username); await _bus.SendCommand(removeCommand); }