From 531ce1bbda5f3909a0701b14377ae08b5c1993cb Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Fri, 12 Mar 2021 21:30:18 +0200 Subject: adding functionality to get rating by userid and postId in rating service --- .vs/slnx.sqlite | Bin 167936 -> 167936 bytes src/app/services/rating.service.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 5dcda80..9e7e654 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/src/app/services/rating.service.ts b/src/app/services/rating.service.ts index 9403575..f3e3265 100644 --- a/src/app/services/rating.service.ts +++ b/src/app/services/rating.service.ts @@ -29,6 +29,13 @@ export class RatingService { return this.putRatingRequest(userId, token, postId, isLike); } + getRatingByUserAndPostWithSessionStorageRequest(postId: Guid): Observable { + const userId = this._tokenService.getUserIdFromSessionStorageToken(); + const token = this._tokenService.getTokenFromSessionStorage(); + + return this.getRatingByUserAndPostRequest(userId, token, postId); + } + createRatingRequest(userId: Guid, authToken: string, postId: Guid, isLike: boolean): Observable { const options = { params: new HttpParams().set('UserId', userId.toString()), @@ -53,4 +60,13 @@ export class RatingService { return this._http.put(AppConstants.API_RATING_URL, body, options); } + + getRatingByUserAndPostRequest(userId: Guid, authToken: string, postId: Guid): Observable { + const options = { + params: new HttpParams().set('UserId', userId.toString()).set('PostId', postId.toString()), + headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken) + }; + + return this._http.get(AppConstants.API_RATING_URL + 'GetByUserAndPost', options); + } } -- cgit v1.2.3