parent
e8d97b306f
commit
270733cee1
@ -0,0 +1,5 @@ |
||||
export interface Businessunit { |
||||
name: string; |
||||
id: number; |
||||
agenceId : number; |
||||
} |
@ -0,0 +1,40 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient, HttpHeaders} from "@angular/common/http"; |
||||
import {Observable} from "rxjs"; |
||||
import {Businessunit} from "../interfaces/businessunit"; |
||||
import {businessunitsUrl} from "../../ressources/routes/routes"; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class BusinessunitService { |
||||
private businessunitsUrl = businessunitsUrl; |
||||
|
||||
httpOptions = { |
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }) |
||||
}; |
||||
|
||||
constructor(private http: HttpClient) { } |
||||
|
||||
getBusinessunits():Observable<Businessunit[]> { |
||||
return this.http.get<Businessunit[]>(this.businessunitsUrl); |
||||
} |
||||
|
||||
getBusinessunit(id : number):Observable<Businessunit>{ |
||||
return this.http.get<Businessunit>(this.businessunitsUrl+"/"+id); |
||||
} |
||||
|
||||
updateBusinessunit(businessunit : Businessunit):Observable<Businessunit>{ |
||||
let body = JSON.stringify(businessunit); |
||||
return this.http.put<Businessunit>(this.businessunitsUrl + "/" + businessunit.id, body, this.httpOptions); |
||||
} |
||||
|
||||
deleteBusinessunit(businessunit: Businessunit) { |
||||
return this.http.delete(this.businessunitsUrl + "/" + businessunit.id); |
||||
} |
||||
|
||||
addBusinessunit(businessunit: Businessunit): Observable<Businessunit> { |
||||
let body = JSON.stringify(businessunit); |
||||
return this.http.post<Businessunit>(this.businessunitsUrl, body, this.httpOptions); |
||||
} |
||||
} |
@ -1,2 +1,3 @@ |
||||
export const collaborateursUrl = 'https://localhost:7125/api/collaborateurs'; |
||||
export const agencesUrl = 'https://localhost:7125/api/agences'; |
||||
export const businessunitsUrl = 'https://localhost:7125/api/businessunits'; |
||||
|
Loading…
Reference in new issue