Skip to content

Commit a82a791

Browse files
committed
videogame.service a medio crear
1 parent 6bde4ea commit a82a791

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { Injectable } from "@angular/core";
2+
import { HttpClient } from "@angular/common/http";
3+
4+
import { News } from "../models/new.model"
5+
import { Videogame } from "../models/videojuego.model";
6+
import { Observable } from "rxjs";
7+
import { Usero } from "../models/usero.model";
8+
9+
const URL = '/api/news/';
10+
11+
/////////////////////////////////////////////////////////////////////
12+
// FALTA REVISAR Q FUNCIONE BIEN, Y DOS FUNCIONES MAS ABAJO
13+
/////////////////////////////////////////////////////////////////////
14+
15+
@Injectable({ providedIn: 'root' })
16+
export class VideogameService {
17+
18+
constructor(private httpClient: HttpClient) {}
19+
20+
getVideogames(): Observable<Videogame> {
21+
return this.httpClient.get(URL).pipe() as Observable<Videogame>
22+
}
23+
24+
findVideogamePage() {
25+
return this.httpClient.get(URL + "pages")
26+
}
27+
28+
getVideogame(id: number) {
29+
return this.httpClient.get(URL + id)
30+
}
31+
32+
createVideogame(videogame: Videogame) {
33+
if (!videogame.id) {
34+
return this.httpClient.post(URL, videogame)
35+
} else {
36+
return this.httpClient.put(URL + videogame.id, videogame)
37+
}
38+
}
39+
40+
updateVideogame(videogame: Videogame) {
41+
return this.httpClient.put(URL + videogame.id, videogame)
42+
}
43+
44+
deleteVideogame(videogame: Videogame) {
45+
return this.httpClient.delete(URL + videogame.id)
46+
}
47+
48+
uploadVideogameCompanyImage(videogame: Videogame, formData: FormData) {
49+
return this.httpClient.post(URL + videogame.id + '/companyImage', formData)
50+
}
51+
52+
downloadVideogameCompanyImage(videogame: Videogame) {
53+
return this.httpClient.get(URL + videogame.id + '/companyImage')
54+
}
55+
56+
deleteVideogameCompanyImage(videogame: Videogame) {
57+
return this.httpClient.delete(URL + videogame.id + '/companyImage')
58+
}
59+
/*
60+
addRelatedNew(videogame: Videogame) {
61+
return this.httpClient.put()
62+
}
63+
*/
64+
////////////////////////////////// GRAFICAS ///////////////////////////////////////
65+
66+
67+
graphic() {
68+
return this.httpClient.get(URL + "stats/genres")
69+
}
70+
71+
graphic2() {
72+
return this.httpClient.get(URL + "stats/sales")
73+
}
74+
/*
75+
purchaseVideogame(videogame: Videogame, user: Usero) {
76+
return this.httpClient.put()
77+
}
78+
*/
79+
}

0 commit comments

Comments
 (0)