2018-10-30 16:31:16 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
|
|
|
import { Observable } from 'rxjs/Rx';
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class SubjectsService {
|
|
|
|
|
|
|
|
constructor(private http:Http) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
addSubjects(url: string, subjects:any) {
|
|
|
|
let headers = new Headers({'Content-Type': 'application/json'});
|
|
|
|
let options = new RequestOptions({headers: headers});
|
|
|
|
|
|
|
|
let body = JSON.stringify(subjects);
|
|
|
|
|
|
|
|
return this.http.post(url, body, options)
|
2019-02-14 13:20:00 +01:00
|
|
|
//.do(request => console.log("Insert Response:"+request.status))
|
2018-10-30 16:31:16 +01:00
|
|
|
.map(res => res.json())
|
|
|
|
.map(res => {
|
|
|
|
res["method"]="post";
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
removeSubjects(url: string, subjects:any) {
|
|
|
|
let headers = new Headers({'Content-Type': 'application/json'});
|
|
|
|
|
|
|
|
let body = JSON.stringify(subjects);
|
|
|
|
let options = new RequestOptions({headers: headers,body:body});
|
|
|
|
|
|
|
|
return this.http.delete(url, options)
|
2019-02-14 13:20:00 +01:00
|
|
|
//.do(request => console.log("Delete Response:"+request.status))
|
2018-10-30 16:31:16 +01:00
|
|
|
.map(res => res.json())
|
|
|
|
.map(res => {
|
|
|
|
res["method"]="delete";
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|