Website Summary Files Commits Branches @commit @diff @stats
path: root / src / app / services
diff options
context:
space:
mode:
Commitafeba5e832d87bc659d72e7d945a78821bd7e7b8 (patch)
Author
 Danail Dimitrov <danaildimitrov321@gmail.com>
2021-03-12 21:16:34 +0200
Committer
 Danail Dimitrov <danaildimitrov321@gmail.com>
2021-03-12 21:16:34 +0200
Files976e35e83c8a859b5cebc62bc98e65505607f7b7 /src/app/services
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.tar
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.tar.gz
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.zip
Parent051da12e0edd5408c902695fbc45ddd15d7972b1 (diff)
adding downVote functionality
1 files changed, 23 insertions, 4 deletions
-rw-r--r--src/app/services/rating.service.ts27
diff --git a/src/app/services/rating.service.ts b/src/app/services/rating.service.ts
index 5a86b67..9403575 100644
--- a/src/app/services/rating.service.ts
+++ b/src/app/services/rating.service.ts
@@ -22,16 +22,35 @@ export class RatingService {
return this.createRatingRequest(userId, token, postId, isLike);
}
+ putRatingWithSessionStorageRequest(postId: Guid, isLike: boolean): Observable<object> {
+ const userId = this._tokenService.getUserIdFromSessionStorageToken();
+ const token = this._tokenService.getTokenFromSessionStorage();
+
+ return this.putRatingRequest(userId, token, postId, isLike);
+ }
+
createRatingRequest(userId: Guid, authToken: string, postId: Guid, isLike: boolean): Observable<object> {
+ const options = {
+ params: new HttpParams().set('UserId', userId.toString()),
+ headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
+ };
const body = {
postId: postId.toString(),
isLike: isLike
- };
+ };
+
+ return this._http.post(AppConstants.API_RATING_URL, body, options);
+ }
+
+ putRatingRequest(userId: Guid, authToken: string, postId: Guid, isLike: boolean): Observable<object> {
const options = {
- params: new HttpParams().set('UserId', userId.toString()),
- headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
+ params: new HttpParams().set('UserId', userId.toString()).set('PostId', postId.toString()),
+ headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
+ };
+ const body = {
+ isLike: isLike
};
- return this._http.post(AppConstants.API_RATING_URL, body, options);
+ return this._http.put(AppConstants.API_RATING_URL, body, options);
}
}