From 777a7edae0ba434b908a733c1c939cabcee35c24 Mon Sep 17 00:00:00 2001
From: Hagen <hagen.dressler@mni.thm.de>
Date: Wed, 7 Mar 2018 22:57:34 +0100
Subject: [PATCH] Add logic functions to component create-comment

---
 .../create-comment/create-comment.component.ts | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/app/create-comment/create-comment.component.ts b/src/app/create-comment/create-comment.component.ts
index 700643e5e..59e8b2d93 100644
--- a/src/app/create-comment/create-comment.component.ts
+++ b/src/app/create-comment/create-comment.component.ts
@@ -3,6 +3,8 @@ import { ActivatedRoute } from '@angular/router';
 import { Location } from '@angular/common';
 
 import { Room } from '../room';
+import { RoomService } from '../room.service';
+import { CommentService} from '../comment.service';
 
 @Component({
   selector: 'app-create-comment',
@@ -14,18 +16,28 @@ export class CreateCommentComponent implements OnInit {
 
   constructor(
     private route: ActivatedRoute,
+    private roomService: RoomService,
+    private commentService: CommentService,
     private location: Location,
   ) { }
 
   ngOnInit(): void {
-    this.getRoom();
+    // this.getRoom();
   }
 
   getRoom(): void {
-    const id = +this.route.snapshot.paramMap.get('id');
+    const id = this.route.snapshot.paramMap.get('id');
+    this.roomService.getRoom(id)
+      .subscribe(room => this.room = room);
   }
 
-  send(subject: string, text: string): void {}
+  send(subject: string, text: string): void {
+    subject = subject.trim();
+    text = text.trim();
+    if (!subject || !text) { return; }
+    this.commentService.addComment( { subject } as Comment )
+      .subscribe();
+  }
 
   goBack(): void {
     this.location.back();
-- 
GitLab