/* * Delete method, using the user's email, lookup their database entry and remove it. * The catch is in case it cannot find the user... */ public async Task Delete(string email) { // lets see if the pilot with this email even exists try { // TODO: see if remove and entity state deleted are redundent var pilot = GetUser(email).Result; db.Pilots.Remove((Pilot)pilot); db.Entry(pilot).State = EntityState.Deleted; await db.SaveChangesAsync(); } catch (System.ArgumentNullException) { } // doesn't exist-->need to handle this better }
/* * Asynchronus delete from flight database * will catch if flight could not be found in table */ public async Task Delete(DateTime takeOff, string routeId) { try { var flight = await GetFlight(takeOff, routeId); db.Flights.Remove((Flight)flight); db.Entry(flight).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; await db.SaveChangesAsync(); } catch (ArgumentNullException) { }; }