league service
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { IRaceRegistrationRepository } from '@gridpilot/racing/domain/repositories/IRaceRegistrationRepository';
|
||||
import type { IRaceRegistrationRepository } from '../../domain/repositories/IRaceRegistrationRepository';
|
||||
import type { IsDriverRegisteredForRaceQueryParamsDTO } from '../dto/RaceRegistrationQueryDTO';
|
||||
import type { IDriverRegistrationStatusPresenter } from '../presenters/IDriverRegistrationStatusPresenter';
|
||||
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
||||
|
||||
/**
|
||||
* Use Case: IsDriverRegisteredForRaceUseCase
|
||||
@@ -8,15 +9,15 @@ import type { IDriverRegistrationStatusPresenter } from '../presenters/IDriverRe
|
||||
* Checks if a driver is registered for a specific race.
|
||||
* Orchestrates domain logic and delegates presentation to the presenter.
|
||||
*/
|
||||
export class IsDriverRegisteredForRaceUseCase {
|
||||
constructor(
|
||||
private readonly registrationRepository: IRaceRegistrationRepository,
|
||||
public readonly presenter: IDriverRegistrationStatusPresenter,
|
||||
) {}
|
||||
export class IsDriverRegisteredForRaceUseCase
|
||||
implements UseCase<IsDriverRegisteredForRaceQueryParamsDTO, boolean, any, IDriverRegistrationStatusPresenter>
|
||||
{
|
||||
constructor(private readonly registrationRepository: IRaceRegistrationRepository) {}
|
||||
|
||||
async execute(params: IsDriverRegisteredForRaceQueryParamsDTO): Promise<void> {
|
||||
async execute(params: IsDriverRegisteredForRaceQueryParamsDTO, presenter: IDriverRegistrationStatusPresenter): Promise<void> {
|
||||
presenter.reset();
|
||||
const { raceId, driverId } = params;
|
||||
const isRegistered = await this.registrationRepository.isRegistered(raceId, driverId);
|
||||
this.presenter.present(isRegistered, raceId, driverId);
|
||||
presenter.present(isRegistered, raceId, driverId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user