|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { HttpClient } from "@angular/common/http";
|
|
|
|
|
import { Observable, from } from "rxjs";
|
|
|
|
|
|
|
|
|
|
import { Race } from '../models/race.model';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class RacesService {
|
|
|
|
|
|
|
|
|
|
constructor(private httpClient: HttpClient) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getAllRaces(): Observable<Array<Race>> {
|
|
|
|
|
return this.httpClient.get<Array<Race>>("assets/races.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getRace(id: string) {
|
|
|
|
|
return this.httpClient.get("http://172.16.40.146:3000/races/"+id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getRaceResults(id: string) {
|
|
|
|
|
return this.httpClient.get("http://172.16.40.146:3000/races/"+id+"/results");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getMapInfo(mapUID: string) {
|
|
|
|
|
return this.httpClient.get("http://172.16.40.146:3000/races/map/"+mapUID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
create(mapUID: string, startDate: Date, endDate: Date, seasonId: number) {
|
|
|
|
|
return this.httpClient.post("http://172.16.40.146:3000/races", { mapUID: mapUID, startDate: startDate, endDate: endDate, seasonId: seasonId});
|
|
|
|
|
}
|
|
|
|
|
}
|