From 142eae4b31e0a50f3c029c61311f153964474b9c Mon Sep 17 00:00:00 2001 From: Sonja Galovic Date: Wed, 2 Mar 2022 19:18:15 +0100 Subject: Dodata testna aplikacija. --- .../front/src/app/services/student.service.spec.ts | 16 +++++++++++ .../front/src/app/services/student.service.ts | 31 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 sandbox/testAppSonja/frontend/front/src/app/services/student.service.spec.ts create mode 100644 sandbox/testAppSonja/frontend/front/src/app/services/student.service.ts (limited to 'sandbox/testAppSonja/frontend/front/src/app/services') diff --git a/sandbox/testAppSonja/frontend/front/src/app/services/student.service.spec.ts b/sandbox/testAppSonja/frontend/front/src/app/services/student.service.spec.ts new file mode 100644 index 00000000..85cfc63f --- /dev/null +++ b/sandbox/testAppSonja/frontend/front/src/app/services/student.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { StudentService } from './student.service'; + +describe('StudentService', () => { + let service: StudentService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(StudentService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/sandbox/testAppSonja/frontend/front/src/app/services/student.service.ts b/sandbox/testAppSonja/frontend/front/src/app/services/student.service.ts new file mode 100644 index 00000000..b0eb60cc --- /dev/null +++ b/sandbox/testAppSonja/frontend/front/src/app/services/student.service.ts @@ -0,0 +1,31 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Student } from '../Student'; + +@Injectable({ + providedIn: 'root' +}) +export class StudentService { + + constructor(private http: HttpClient) { } + + public getStudents() { + return this.http.get(`http://localhost:5000/api/students`); + } + + public getOneStudent(id: number) { + return this.http.get("http://localhost:5000/api/students/" + id); + } + + public updateStudent(id: number, student: Student) { + return this.http.put("http://localhost:5000/api/students/" + student.id, student); + } + + public deleteStudent(id: number) { + return this.http.delete("http://localhost:5000/api/students/" + id); + } + + public addStudent(newStudent: Student) { + return this.http.post("http://localhost:5000/api/students/", newStudent); + } +} -- cgit v1.2.3