Fix
This commit is contained in:
33
Front/skydivelogs-app/src/services/tunnel-flight.service.ts
Normal file
33
Front/skydivelogs-app/src/services/tunnel-flight.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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});
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,13 @@ import { HttpClient } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { TunnelResp, TunnelReq } from "../models/tunnel";
|
||||
import { TunnelResp } from "../models/tunnel";
|
||||
|
||||
import { BaseService } from "./base.service";
|
||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
|
||||
@Injectable()
|
||||
export class TunnelService extends BaseService {
|
||||
private datePipe: DatePipe;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
@@ -22,23 +21,6 @@ export class TunnelService extends BaseService {
|
||||
return this.serviceCacheApi.get<Array<TunnelResp>>(CacheApiKey.Gear, callToApi);
|
||||
}
|
||||
|
||||
public AddFlight(selectedTunnel: number,
|
||||
flightDate: Date,
|
||||
nbMinutes: number,
|
||||
comment: string)
|
||||
{
|
||||
|
||||
const bodyNewFlight: TunnelReq = {
|
||||
id: 0,
|
||||
tunnelId: selectedTunnel,
|
||||
flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"),
|
||||
comment: comment,
|
||||
nbMinutes: nbMinutes
|
||||
};
|
||||
|
||||
return this.http.post(`${this.apiUrl}/Tunnel`, bodyNewFlight, { headers: this.headers});
|
||||
}
|
||||
|
||||
public getById(id: number) : Observable<TunnelResp> {
|
||||
return this.serviceCacheApi.getByKey<Array<TunnelResp>>(CacheApiKey.Tunnel)
|
||||
.pipe(map(data => {
|
||||
|
||||
Reference in New Issue
Block a user