import { Injectable } from "@angular/core"; import { DatePipe } from "@angular/common"; import { HttpClient } from "@angular/common/http"; import { TunnelFlightReq } from "../models/tunnel-flight"; import { BaseService } from "./base.service"; @Injectable() export class TunnelFlightService extends BaseService { private datePipe: DatePipe; constructor(private http: HttpClient) { super(); } public addFlight(selectedTunnel: number, flightDate: Date, nbMinutes: number, comment: string) { const bodyNewFlight: TunnelFlightReq = { id: 0, tunnelId: selectedTunnel, flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"), notes: comment, nbMinutes: nbMinutes }; return this.http.post(`${this.apiUrl}/TunnelFlight`, bodyNewFlight, { headers: this.headers}); } }