Files
frontend/src/app/http.service.ts

78 lines
2.4 KiB
TypeScript

import {Kinosaal, Sitzplatz, Vorstellung} from '@infinimotion/model-frontend';
import { HttpClient } from "@angular/common/http";
import { inject, Injectable } from "@angular/core";
import { Observable } from "rxjs";
@Injectable({
providedIn: 'root'
})
export class HttpService {
private http = inject(HttpClient);
private baseUrl = 'https://infinimotion.de/api/';
/* Kinosaal APIs */
/* GET /api/kinosaal */
getAllKinosaal(): Observable<Kinosaal[]> {
return this.http.get<Kinosaal[]>(`${this.baseUrl}kinosaal`);
}
/* GET /api/kinosaal/{id} */
getKinosaalById(id: number): Observable<Kinosaal> {
return this.http.get<Kinosaal>(`${this.baseUrl}kinosaal/${id}`);
}
/* POST /api/kinosaal */
addKinosaal(kinosaal: Omit<Kinosaal, 'id'>): Observable<Kinosaal> {
return this.http.post<Kinosaal>(`${this.baseUrl}kinosaal`, kinosaal);
}
/* PUT /api/kinosaal/{id} */
updateKinosaal(id: number, kinosaal: Partial<Kinosaal>): Observable<Kinosaal> {
return this.http.put<Kinosaal>(`${this.baseUrl}kinosaal/${id}`, kinosaal);
}
/* DELETE /api/kinosaal/{id} */
deleteKinosaal(id: number): Observable<void> {
return this.http.delete<void>(`${this.baseUrl}kinosaal/${id}`);
}
/* Vorstellung APIs */
/* GET /api/vorstellung */
getPerformaces(): Observable<Vorstellung[]> {
return this.http.get<Vorstellung[]>(`${this.baseUrl}vorstellung`);
}
/* GET /api/vorstellung/{id} */
getPerformaceById(id: number): Observable<Vorstellung> {
return this.http.get<Vorstellung>(`${this.baseUrl}vorstellung/${id}`);
}
/* POST /api/vorstellung */
addPerformace(vorstellung: Omit<Vorstellung, 'id'>): Observable<Vorstellung> {
return this.http.post<Vorstellung>(`${this.baseUrl}vorstellung`, vorstellung);
}
/* PUT /api/vorstellung/{id} */
updatePerformace(id: number, vorstellung: Partial<Vorstellung>): Observable<Vorstellung> {
return this.http.put<Vorstellung>(`${this.baseUrl}vorstellung/${id}`, vorstellung);
}
/* DELETE /api/vorstellung/{id} */
deletePerformace(id: number): Observable<void> {
return this.http.delete<void>(`${this.baseUrl}vorstellung/${id}`);
}
/* Show-Seats APIs*/
/* GET /api/show-seats/{show} */
getSeatsByShowId(show: number): Observable<{seats:Sitzplatz[], reserved:Sitzplatz[], booked:Sitzplatz[]}> {
return this.http.get<{seats:Sitzplatz[], reserved:Sitzplatz[], booked:Sitzplatz[]}>(`${this.baseUrl}show-seats/${show}`);
}
}