git init v2
This commit is contained in:
45
src/app/services/appointment.service.ts
Normal file
45
src/app/services/appointment.service.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Appointment} from '../models/appointment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AppointmentService {
|
||||
baseApi = "http://localhost:8080/api/appointments";
|
||||
// baseApi = "https://api.melvanveen.nl/api/appointments";
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
getAllAppointments() {
|
||||
return this.http.get<Appointment[]>(`${this.baseApi}`);
|
||||
}
|
||||
|
||||
getAppointmentsByDate(date: Date) {
|
||||
const day = date.getDate().toString().padStart(2, '0')
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
||||
const year = date.getFullYear();
|
||||
return this.http.get<Appointment[]>(`${this.baseApi}/date?start=${year}-${month}-${day}`, {});
|
||||
}
|
||||
|
||||
addAppointment(appointment: Appointment) {
|
||||
return this.http.post(`${this.baseApi}`, appointment);
|
||||
}
|
||||
|
||||
deleteAppointment(appointment: Appointment) {
|
||||
return this.http.delete(`${this.baseApi}?id=${appointment.id}`)
|
||||
}
|
||||
|
||||
updateAppointment(appointment: Appointment) {
|
||||
return this.http.put(`${this.baseApi}`, appointment);
|
||||
}
|
||||
|
||||
getAppointment(id: string) {
|
||||
return this.http.get(`${this.baseApi}/${id}`);
|
||||
}
|
||||
|
||||
getMostRecentAppointment(id: number) {
|
||||
return this.http.get(`${this.baseApi}/recent/${id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user