private void LoadFlights(IDatabaseContext stubDB) { //first flight var dt1 = new DateTime(2020, 1, 1, 10, 00, 00, DateTimeKind.Utc); //2020-01-01T10:00:00Z var initialLoc = new InitialFlightLocation(); initialLoc.Longitude = 20; initialLoc.Latitude = 20; initialLoc.DateTime = dt1; var seg = new FlightSegment(); seg.Latitude = 24; seg.Longitude = 24; seg.TimespanSeconds = 3600; //one hour later var segments = new List <FlightSegment>(); segments.Add(seg); var f1 = new FlightPlan(); f1.FlightId = "1"; f1.CompanyName = "1"; f1.Passengers = 1; f1.InitialLocation = initialLoc; f1.Segments = segments; stubDB.AddFlightPlan(f1); //second flight dt1 = new DateTime(2020, 1, 1, 10, 15, 00, DateTimeKind.Utc); //2020-01-01T10:15:00Z initialLoc = new InitialFlightLocation(); initialLoc.Longitude = 30; initialLoc.Latitude = 30; initialLoc.DateTime = dt1; segments = new List <FlightSegment>(); var seg1 = new FlightSegment(); seg1.Latitude = 31; seg1.Longitude = 31; seg1.TimespanSeconds = 900; //15 minites later segments.Add(seg1); var seg2 = new FlightSegment(); seg2.Latitude = 32; seg2.Longitude = 32; seg2.TimespanSeconds = 900; //15 minites later segments.Add(seg2); var f2 = new FlightPlan(); f2.FlightId = "2"; f2.CompanyName = "2"; f2.Passengers = 2; f2.InitialLocation = initialLoc; f2.Segments = segments; stubDB.AddFlightPlan(f2); }
// Add Flight Plan to database and return the unique id. public async Task <string> AddFlightPlan(FlightPlan flightPlan) { // Check if the object is valid. if (!IsValidFlightPlan(flightPlan)) { return("bad"); } // If is valid, return it's id. return(await database.AddFlightPlan(flightPlan)); }