[eed0bf8] | 1 | import { HttpClient } from "@angular/common/http";
|
---|
| 2 | import { Injectable } from "@angular/core";
|
---|
| 3 | import { Observable } from "rxjs";
|
---|
[ceaed42] | 4 | import { PlannerLocationDto } from "../_models/dto/plannerLocationDto";
|
---|
| 5 | import { Location } from "../_models/location";
|
---|
[eed0bf8] | 6 |
|
---|
| 7 | @Injectable({
|
---|
| 8 | providedIn: 'root'
|
---|
| 9 | })
|
---|
| 10 | export class LocationService{
|
---|
| 11 | constructor(private httpClient : HttpClient){}
|
---|
| 12 |
|
---|
[ceaed42] | 13 | getLocationsFromCity(cityId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Location[]>{
|
---|
[188ee53] | 14 | let url = "http://localhost:8080/api/city/locations";
|
---|
| 15 | return this.httpClient.get<Location[]>(url + '?cityId=' + cityId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds);
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | getLocationsFromRegion(regionId: number, companionId: number, lengthOfStay: number, categoryIds: string):Observable<Object[]>{
|
---|
| 19 | let url = "http://localhost:8080/api/region/locations";
|
---|
| 20 | return this.httpClient.get<Location[]>(url + '?regionId=' + regionId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds);
|
---|
[eed0bf8] | 21 | }
|
---|
[ceaed42] | 22 |
|
---|
| 23 | postLocationToPlanner(plannerLocationDto : PlannerLocationDto) : Observable<Location>{
|
---|
| 24 | let url = "http://localhost:8080/api/add-location";
|
---|
| 25 | return this.httpClient.put<Location>(url, plannerLocationDto);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[59329aa] | 28 | getLocationsForPlanner(plannerId : number) : Observable<Location[]>{
|
---|
[ceaed42] | 29 | let url = "http://localhost:8080/api/planner/locations";
|
---|
| 30 | return this.httpClient.get<Location[]>(url + '?plannerId=' + plannerId);
|
---|
| 31 | }
|
---|
[59329aa] | 32 |
|
---|
| 33 | getAllLocations() : Observable<Location[]> {
|
---|
| 34 | let url = "http://localhost:8080/api/locations";
|
---|
| 35 | return this.httpClient.get<Location[]>(url);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | getWeekendGetaways() : Observable<Location[]>{
|
---|
| 39 | let url = "http://localhost:8080/api/weekend";
|
---|
| 40 | return this.httpClient.get<Location[]>(url);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | getVillages() : Observable<Location[]>{
|
---|
| 44 | let url = "http://localhost:8080/api/villages";
|
---|
| 45 | return this.httpClient.get<Location[]>(url);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | getLocation(id : number) :Observable<Location>{
|
---|
| 49 | let url = "http://localhost:8080/api/location/" + id;
|
---|
| 50 | return this.httpClient.get<Location>(url);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | getAllLocationsForPlanner(id: number): Observable<Location[]>{
|
---|
| 54 | let url = "http://localhost:8080/api/planner/locations";
|
---|
| 55 | return this.httpClient.get<Location[]>(url + "?plannerId=" + id);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[eed0bf8] | 58 | } |
---|