Introduced get, add, update, and delete methods for Kinosaal entities using a base API URL. Updated getAllKinosaal to return an array and refactored endpoints to use relative paths.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Kinosaal } 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 = '/api/';
|
|
|
|
/* 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}`);
|
|
}
|
|
}
|