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

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

disabling to add location if it already exists in the planner

  • Property mode set to 100644
File size: 2.6 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 getLocationsForPlanner(plannerId : number) : Observable<Location[]>{
29 let url = "http://localhost:8080/api/planner/locations";
30 return this.httpClient.get<Location[]>(url + '?plannerId=' + plannerId);
31 }
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
58 getAllLocationIdsForPlanner(id:number):Observable<number[]>{
59 let url = "http://localhost:8080/api/planner/locationIds";
60 return this.httpClient.get<number[]>(url + "?plannerId="+id);
61 }
62
63}
Note: See TracBrowser for help on using the repository browser.