Fix about the favorite DZ

This commit is contained in:
Sébastien André
2021-03-25 16:57:30 +01:00
parent 0a6dbf42e4
commit 9d51f38f2e
10 changed files with 45 additions and 52 deletions

View File

@@ -72,9 +72,9 @@ export class AuthenticationService extends BaseService {
}
private alwaysLogin() {
return this.http.get(`${this.apiUrl}/User/AlwayLogin`, {
return this.http.get(`${this.apiUrl}/User/AlwaysLogin`, {
headers: this.headers
});
}).subscribe();
}
logout() {

View File

@@ -14,50 +14,42 @@ export class DropzoneService extends BaseService {
}
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
return this.http
.get<Array<DropZoneResp>>(`${this.apiUrl}/DropZone`, {
headers: this.headers
})
.pipe(
map(response => {
const details = response.map(data => new DropZoneResp(data));
return details;
})
);
return this.http.get<Array<DropZoneResp>>(`${this.apiUrl}/DropZone`,
{ headers: this.headers })
.pipe(map(response => {
const details = response.map(data => new DropZoneResp(data));
return details;
}));
}
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
selectedDz.isFavorite = true;
this.http
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
headers: this.headers
})
.subscribe(data => console.log(data));
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
selectedDz,
{ headers: this.headers })
.subscribe(data => console.log(data));
return true;
}
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
selectedDz.isFavorite = false;
this.http
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
headers: this.headers
})
.subscribe(data => console.log(data));
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
selectedDz,
{ headers: this.headers })
.subscribe(data => console.log(data));
return true;
}
public AddDropZone(
latitude: string,
longitude: string,
name: string,
address: string,
website: string,
email: string,
type: Array<string>,
isFavorite: boolean
) {
public AddDropZone(latitude: string,
longitude: string,
name: string,
address: string,
website: string,
email: string,
type: Array<string>,
isFavorite: boolean) {
const bodyNewDropZone: DropZoneReq = {
id: 0,
latitude: latitude,
@@ -70,10 +62,9 @@ export class DropzoneService extends BaseService {
isFavorite: isFavorite
};
this.http
.post(`${this.apiUrl}/DropZone`, bodyNewDropZone, {
headers: this.headers
})
.subscribe(data => console.log(data));
this.http.post(`${this.apiUrl}/DropZone`,
bodyNewDropZone,
{ headers: this.headers })
.subscribe(data => console.log(data));
}
}