예제 #1
0
        public void DeleteFlight(int id)
        {
            var flight = context.Flights.Find(id);

            if (flight != null)
            {
                context.Remove(flight);
                context.SaveChanges();
            }
        }
예제 #2
0
        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);
            }
        }