Files
gilze-angular/app/classes/flight.class.ts
T
2026-06-17 16:11:25 +02:00

73 lines
1.4 KiB
TypeScript

import { User } from './user.class';
import { Plane } from './plane.class';
export class Flight {
id:number;
flightday_id:number;
starttime:string;
endtime:string;
type:string;
comment:string;
plane:Plane
users:Array<User>;
constructor(id:number,
flightday_id:number,
starttime:string,
endtime:string,
type:string,
comment:string,
plane:Plane,
users:Array<User>)
{
this.id = id;
this.flightday_id = flightday_id;
this.plane = plane;
this.starttime = starttime;
this.endtime = endtime;
this.type = type;
this.comment = comment;
this.users = users;
}
public equals(other:Flight) : boolean
{
if(other)
{
var keySet1 = Object.keys(this);
var keySet2 = Object.keys(other);
var j = 0;
var isTheSame = true;
for(j; j < keySet1.length; j++) {
if (this[keySet1[j]] !== other[keySet2[j]]) {
// Shit is not the same
isTheSame = false;
}
}
return isTheSame;
}
return false;
}
public static toFlight(r:any): Flight
{
let users:Array<User> = new Array<User>();
let plane:Plane = Plane.toPlane(r.PLANE);
for(let i = 0; i < r.USERS.length; i++)
{
users.push(User.toUser(r.USERS[i]));
}
let flight = new Flight(r.ID, r.FLIGHTDAY_ID, r.DATETIME_START, r.DATETIME_END, r.TYPE, r.COMMENT, plane, users);
return flight;
}
}