aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-12 21:30:18 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-12 21:30:18 +0200
commit531ce1bbda5f3909a0701b14377ae08b5c1993cb (patch)
tree73bef4ad9f61868577b51045469422136f441a1c /src/app
parentafeba5e832d87bc659d72e7d945a78821bd7e7b8 (diff)
downloadDevHive-Angular-531ce1bbda5f3909a0701b14377ae08b5c1993cb.tar
DevHive-Angular-531ce1bbda5f3909a0701b14377ae08b5c1993cb.tar.gz
DevHive-Angular-531ce1bbda5f3909a0701b14377ae08b5c1993cb.zip
adding functionality to get rating by userid and postId in rating service
Diffstat (limited to 'src/app')
-rw-r--r--src/app/services/rating.service.ts16
1 files changed, 16 insertions, 0 deletions
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<object> {
+ 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<object> {
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<object> {
+ 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);
+ }
}