import { HttpClient } from "@angular/common/http"; import { Injectable } from "@angular/core"; import { Observable } from "rxjs"; import { PlannerLocationDto } from "../_models/dto/plannerLocationDto"; import { Location } from "../_models/location"; @Injectable({ providedIn: 'root' }) export class LocationService{ constructor(private httpClient : HttpClient){} getLocationsFromCity(cityId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable{ let url = "http://localhost:8080/api/city/locations"; return this.httpClient.get(url + '?cityId=' + cityId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds); } getLocationsFromRegion(regionId: number, companionId: number, lengthOfStay: number, categoryIds: string):Observable{ let url = "http://localhost:8080/api/region/locations"; return this.httpClient.get(url + '?regionId=' + regionId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds); } postLocationToPlanner(plannerLocationDto : PlannerLocationDto) : Observable{ let url = "http://localhost:8080/api/add-location"; return this.httpClient.put(url, plannerLocationDto); } getLocationsForPlanner(plannerId : number) : Observable{ let url = "http://localhost:8080/api/planner/locations"; return this.httpClient.get(url + '?plannerId=' + plannerId); } getAllLocations() : Observable { let url = "http://localhost:8080/api/locations"; return this.httpClient.get(url); } getWeekendGetaways() : Observable{ let url = "http://localhost:8080/api/weekend"; return this.httpClient.get(url); } getVillages() : Observable{ let url = "http://localhost:8080/api/villages"; return this.httpClient.get(url); } getLocation(id : number) :Observable{ let url = "http://localhost:8080/api/location/" + id; return this.httpClient.get(url); } getAllLocationsForPlanner(id: number): Observable{ let url = "http://localhost:8080/api/planner/locations"; return this.httpClient.get(url + "?plannerId=" + id); } getAllLocationIdsForPlanner(id:number):Observable{ let url = "http://localhost:8080/api/planner/locationIds"; return this.httpClient.get(url + "?plannerId="+id); } }