Skip to content

Commit

Permalink
Change DeleteTermCommandHandler #178
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Jan 11, 2025
1 parent e76459b commit a160ed3
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default class DeleteTermCommandHandler implements ICommandHandler<DeleteT
) {}

async execute(command: DeleteTermCommand): Promise<void> {
const termId = TermId.of(command.id);
const term = await this.getTerm(termId);
const term = await this.getTerm(command.id);

term.delete();

Expand All @@ -25,8 +24,8 @@ export default class DeleteTermCommandHandler implements ICommandHandler<DeleteT
void this.eventBus.publish(term.pullDomainEvents());
}

private async getTerm(termId: TermId): Promise<Term> {
const term = await this.termRepository.findById(termId);
private async getTerm(termId: string): Promise<Term> {
const term = await this.termRepository.findById(TermId.of(termId));
if (!term) {
throw new TermDoesNotExistsException(termId.toString());
}
Expand Down

0 comments on commit a160ed3

Please sign in to comment.