league service
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { IGetLeagueSeasonsPresenter, GetLeagueSeasonsResultDTO, GetLeagueSeasonsViewModel } from '@gridpilot/racing/application/presenters/IGetLeagueSeasonsPresenter';
|
||||
|
||||
export class GetLeagueSeasonsPresenter implements IGetLeagueSeasonsPresenter {
|
||||
private result: GetLeagueSeasonsViewModel | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(dto: GetLeagueSeasonsResultDTO) {
|
||||
const seasons = dto.seasons.map(season => ({
|
||||
seasonId: season.id,
|
||||
name: season.name,
|
||||
status: season.status,
|
||||
startDate: season.startDate,
|
||||
endDate: season.endDate,
|
||||
isPrimary: season.isPrimary,
|
||||
isParallelActive: season.isParallelActive,
|
||||
}));
|
||||
this.result = { seasons };
|
||||
}
|
||||
|
||||
getViewModel(): GetLeagueSeasonsViewModel {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user