introduce an endpoint and service to update the active runway and arrival mode
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
مرجع در شماره جدید
Block a user