source: trip-planner-front/src/app/_services/location.service.ts@ ceaed42

Last change on this file since ceaed42 was ceaed42, checked in by Ema <ema_spirova@…>, 3 years ago

add location to planner

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import { HttpClient } from "@angular/common/http";
2import { Injectable } from "@angular/core";
3import { Observable } from "rxjs";
4import { PlannerLocationDto } from "../_models/dto/plannerLocationDto";
5import { Location } from "../_models/location";
6
7@Injectable({
8 providedIn: 'root'
9})
10export class LocationService{
11 constructor(private httpClient : HttpClient){}
12
13 getLocationsFromCity(cityId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Location[]>{
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);
21 }
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
28 getLocationsFroPlanner(plannerId : number) : Observable<Location[]>{
29 let url = "http://localhost:8080/api/planner/locations";
30 return this.httpClient.get<Location[]>(url + '?plannerId=' + plannerId);
31 }
32}
Note: See TracBrowser for help on using the repository browser.