introduce an endpoint and service to update the active runway and arrival mode

This commit is contained in:
Sven Czarnian
2022-10-25 08:26:39 +02:00
والد 71589fe1b4
کامیت abe73cdd8b
3فایلهای تغییر یافته به همراه77 افزوده شده و 0 حذف شده

مشاهده پرونده

@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { ActiveRunwaysDto } from './dto/activerunways.dto';
import { Airport, AirportDocument } from './models/airport.model';
@Injectable()
@@ -57,4 +58,17 @@ export class AirportService {
async deleteAirport(icao: string): Promise<void> {
this.airportModel.deleteOne({ icao });
}
async activateRunways(runways: ActiveRunwaysDto): Promise<boolean> {
return this.airportExists(runways.icao).then(async (exists) => {
if (exists) {
await this.airportModel.findOneAndUpdate(
{ icao: runways.icao },
{ activeRunways: runways.runways, arrivalMode: runways.mode },
);
}
return exists;
});
}
}