diff options
Diffstat (limited to 'sandbox/TestIvanLjubisavljevic/frontend/src/app/services')
| -rwxr-xr-x | sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts | 16 | ||||
| -rwxr-xr-x | sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts | 61 | 
2 files changed, 77 insertions, 0 deletions
diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts new file mode 100755 index 00000000..c64a4343 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LibraryServiceService } from './library.service'; + +describe('LibraryService', () => { +  let service: LibraryServiceService; + +  beforeEach(() => { +    TestBed.configureTestingModule({}); +    service = TestBed.inject(LibraryServiceService); +  }); + +  it('should be created', () => { +    expect(service).toBeTruthy(); +  }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts new file mode 100755 index 00000000..e16759d9 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts @@ -0,0 +1,61 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http'; +import { Laptop } from '../models/laptop'; + +@Injectable({ +  providedIn: 'root' +}) + +export class LibraryServiceService    { +   +  constructor(private http:HttpClient) { } + +  //DAJ SVE LAPTOPOVE +  dajLaptopove(): Observable<Laptop[]> +  { +      return this.http.get<Laptop[]>("http://localhost:5000/api/sviLaptopovi"); +  } + +  //DAJ ODREDJENI LAPTOP +  dajLaptop(id:String): Observable<Laptop> +  { +    return this.http.get<Laptop>("http://localhost:5000/api/laptop/"+id); +  } + +  //UNESI NOVI LAPTOP +  unesiLaptop(reqBody:Laptop): Observable<Laptop> +  { +    return this.http.post<Laptop>("http://localhost:5000/api/add",  +    {"brand": reqBody.brand, +    "model": reqBody.model, +    "ram": reqBody.ram, +    "hdd": reqBody.hdd, +    "graphics": reqBody.graphics, +    "price":reqBody.price, +    "display" : reqBody.display, +    "id": "a873b90f-5fca-4c41-a00e-8ea497cce542", +    "processor": reqBody.processor}); +  } + +  //IZMENI LAPTOP +  izmeniLaptop(reqBody?:Laptop): Observable<Laptop> +  { +    return this.http.put<Laptop>("http://localhost:5000/api/update",  +    {"brand": reqBody?.brand, +    "model": reqBody?.model, +    "ram": reqBody?.ram, +    "hdd": reqBody?.hdd, +    "graphics": reqBody?.graphics, +    "price":reqBody?.price, +    "display" : reqBody?.display, +    "processor": reqBody?.processor, +  "id":reqBody?.id}); +  } + +  //OBRISI LAPTOP +  obrisiLaptop(id:String): Observable<Boolean> +  { +    return this.http.delete<Boolean>("http://localhost:5000/api/brisanje/"+id); +  } +}
\ No newline at end of file  | 
