aboutsummaryrefslogtreecommitdiff
path: root/src/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/components')
-rw-r--r--src/app/components/post/post.component.html2
-rw-r--r--src/app/components/post/post.component.ts35
2 files changed, 36 insertions, 1 deletions
diff --git a/src/app/components/post/post.component.html b/src/app/components/post/post.component.html
index 4584591..830fa75 100644
--- a/src/app/components/post/post.component.html
+++ b/src/app/components/post/post.component.html
@@ -36,7 +36,7 @@
<summary class="score">
{{ votesNumber }}
</summary>
- <button class="vote">
+ <button class="vote" (click)="downVotePost()">
</button>
</section>
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--;
+ }
+ );
+ }
}