diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-03-11 21:57:16 +0200 |
|---|---|---|
| committer | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-03-11 21:57:16 +0200 |
| commit | 051da12e0edd5408c902695fbc45ddd15d7972b1 (patch) | |
| tree | 8b626c44f135f166e9833aa9fbb5d92adb455193 /src/app/services | |
| parent | fe4c9eaeac345c63e0c08c43b9dc3185d07716e8 (diff) | |
| download | DevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.tar DevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.tar.gz DevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.zip | |
added upvote post functionality
Diffstat (limited to 'src/app/services')
| -rw-r--r-- | src/app/services/post.service.ts | 2 | ||||
| -rw-r--r-- | src/app/services/rating.service.ts | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/app/services/post.service.ts b/src/app/services/post.service.ts index 7b2a539..d582085 100644 --- a/src/app/services/post.service.ts +++ b/src/app/services/post.service.ts @@ -15,7 +15,7 @@ export class PostService { { } getDefaultPost(): Post { - return new Post(Guid.createEmpty(), 'Gosho', 'Trapov', 'gosho_trapov', 'Your opinion on my idea?', new Date(), [], []); + return new Post(Guid.createEmpty(), 'Gosho', 'Trapov', 'gosho_trapov', 'Your opinion on my idea?', new Date(), [], [], 0); } /* Requests from session storage */ diff --git a/src/app/services/rating.service.ts b/src/app/services/rating.service.ts index 630a43c..5a86b67 100644 --- a/src/app/services/rating.service.ts +++ b/src/app/services/rating.service.ts @@ -14,4 +14,24 @@ import { TokenService } from './token.service'; export class RatingService { constructor(private _http: HttpClient, private _tokenService: TokenService) { } + + createRatingWithSessionStorageRequest(postId: Guid, isLike: boolean): Observable<object> { + const userId = this._tokenService.getUserIdFromSessionStorageToken(); + const token = this._tokenService.getTokenFromSessionStorage(); + + return this.createRatingRequest(userId, token, postId, isLike); + } + + createRatingRequest(userId: Guid, authToken: string, postId: Guid, isLike: boolean): Observable<object> { + const body = { + postId: postId.toString(), + isLike: isLike + }; + const options = { + params: new HttpParams().set('UserId', userId.toString()), + headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken) + }; + + return this._http.post(AppConstants.API_RATING_URL, body, options); + } } |
