@@ -11,55 +11,21 @@ export class LibraryService {
1111 constructor ( public http : Http ) {
1212 this . headers = new Headers ( )
1313 this . headers . append ( "Content-Type" , "application/json" )
14- /*this.libraries = {}
15- const sampleLibraryData = [
16- {
17- id: 1, name: "sample1", movies: [{ id: 1, imdbId: "tt0120338", title: "Titanic" }],
18- comments: [], ratings: [], user: { username: "alice", id: 123 }
19- },
20- {
21- id: 2, name: "sample2", movies: [
22- { id: 2, imdbId: "tt0096895", title: "Batman" },
23- { id: 3, imdbId: "tt1431045", title: "Deadpool" }],
24- comments: [], ratings: [], user: { username: "alice", id: 123 }
25- },
26- {
27- id: 3, name: "sample3", movies: [
28- { id: 1, imdbId: "tt0120338", title: "Titanic" },
29- { id: 3, imdbId: "tt1431045", title: "Deadpool" }],
30- comments: [], ratings: [], user: { username: "bob", id: 234 }
31- }
32- ]
33- _.forEach(sampleLibraryData, lib => {
34- let model: LibraryModel = LibraryModel.newLibrary(lib)
35- this.libraries[model.id] = model
36- })*/
3714 }
3815
3916 get ( id : number ) {
4017 return this . http . get ( `/api/project/library/${ id } ` ,
4118 { headers : this . headers } )
42- //return this.libraries[id]
4319 }
4420
4521 addLibrary ( library : LibraryModel ) {
4622 return this . http . post ( '/api/project/library' , JSON . stringify ( { library } ) ,
4723 { headers : this . headers } )
48- //this.libraries[library.id] = library
4924 }
5025
5126 getAll ( ) {
5227 return this . http . get ( '/api/project/library' ,
5328 { headers : this . headers } )
54- //return <Array<LibraryModel>> _.values(this.libraries)
55- }
56-
57- getLibrariesWith ( id : string ) : Array < LibraryModel > {
58- return _ . filter ( < Array < LibraryModel > > _ . values ( this . libraries ) , lib => {
59- return _ . some ( lib . movies , movie => {
60- return movie . imdbId === id
61- } )
62- } )
6329 }
6430
6531 updateLibrary ( library ) {
@@ -69,7 +35,6 @@ export class LibraryService {
6935 removeLibrary ( id : number ) {
7036 return this . http . delete ( `/api/project/library/${ id } ` ,
7137 { headers : this . headers } )
72- //delete this.libraries[id]
7338 }
7439
7540 removeMovie ( libraryId : number , movieId : string ) {
0 commit comments