Website Summary Files Commits Branches @commit @diff @stats
path: root / src / app / components / post / post.component.ts
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/components/post/post.component.ts
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.tar
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.tar.gz
DevHive-Angular-afeba5e832d87bc659d72e7d945a78821bd7e7b8.zip
Parent051da12e0edd5408c902695fbc45ddd15d7972b1 (diff)
adding downVote functionality
1 files changed, 35 insertions, 0 deletions
-rw-r--r--src/app/components/post/post.component.ts35
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index 0f48337..168b6a3 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -66,10 +66,45 @@ export class PostComponent implements OnInit {
return;
}
+ this._ratingServe.putRatingWithSessionStorageRequest(Guid.parse(this.paramId), true).subscribe(
+ () => {
+ this.votesNumber += 2;
+ },
+ () => {
+ this.crateUpVoteRating();
+ }
+ );
+ }
+
+ crateUpVoteRating(): void {
this._ratingServe.createRatingWithSessionStorageRequest(Guid.parse(this.paramId), true).subscribe(
() => {
this.votesNumber++;
}
);
}
+
+ downVotePost(): void {
+ if (!this.loggedIn) {
+ this._router.navigate(['/login']);
+ return;
+ }
+
+ this._ratingServe.putRatingWithSessionStorageRequest(Guid.parse(this.paramId), false).subscribe(
+ () => {
+ this.votesNumber -= 2;
+ },
+ () => {
+ this.crateDownVoteRating();
+ }
+ );
+ }
+
+ crateDownVoteRating(): void {
+ this._ratingServe.createRatingWithSessionStorageRequest(Guid.parse(this.paramId), false).subscribe(
+ () => {
+ this.votesNumber--;
+ }
+ );
+ }
}