public void DeleteFlight(int id) { var flight = context.Flights.Find(id); if (flight != null) { context.Remove(flight); context.SaveChanges(); } }
public async Task <bool> Delete(int id) { try { Flight flight = await context.Flights.FirstOrDefaultAsync(f => f.FlightId == id); if (flight != null) { context.Remove(flight); await context.SaveChangesAsync(); return(true); } return(false); } catch (Exception ex) { return(false); } }