// Deleting a server with the ID "id" from context public static async Task <int> DeleteServer(FlightPlanDBContext _context, string id) { Server server = _context.Servers.Where(item => item.ServerId == id).First(); _context.Servers.Remove(server); return(await _context.SaveChangesAsync()); }
// Remove a flight with the same ID as "id" from the ontext given public static async Task <int> RemoveFlight(FlightPlanDBContext _context, string id) { // Finding the flight Flight flight = _context.Flight.Include(item => item.FlightPlan) .Where(item => item.FlightIdentifier == id).First(); FlightPlan flightPlan = flight.FlightPlan; // Removing the associated flight plan _context.FlightPlans.Remove(flightPlan); _context.Flight.Remove(flight); return(await _context.SaveChangesAsync()); }
// Adding a server to the given context public static async Task <int> AddServer(FlightPlanDBContext _context, Server server) { _context.Add(server); return(await _context.SaveChangesAsync()); }
// Send flightPlan and flight to the context given public static async Task <int> AddAFlightPlanAndAFlight(FlightPlanDBContext _context, FlightPlan flightPlan, Flight flight) { _context.Add(flightPlan); _context.Add(flight); return(await _context.SaveChangesAsync()); }