public async Task <Airport> UpdateAirportAsync(Airport airport) { var airportToUpdate = await context.Airport.FirstOrDefaultAsync(a => a.Id == airport.Id); context.Entry(airportToUpdate).CurrentValues.SetValues(new { airport.Iata, airport.Name, airport.MapUrl, airport.MapName, airport.RentingCompanyUrl, airport.RentingCompanyName, airport.RentingCompanyPhoneNo, airport.TaxiPhoneNo, airport.EmergencyPhoneNo, airport.Icao }); var result = await context.SaveChangesAsync(); if (result < 1) { return(null); } return(await context.Airport.FirstOrDefaultAsync(a => a.Id == airportToUpdate.Id)); }
public async Task <News> UpdateNewsAsync(News news) { var newsToUpdate = await context.News.FirstOrDefaultAsync(n => n.Id == news.Id); context.Entry(newsToUpdate).CurrentValues.SetValues(news); var result = await context.SaveChangesAsync(); if (result < 1) { return(null); } return(await context.News.FirstOrDefaultAsync(n => n.Id == news.Id)); }
public async Task <Flight> UpdateFlightAsync(Flight flight) { var flightToUpdate = await context.Flight.SingleOrDefaultAsync(f => f.Id == flight.Id); if (flightToUpdate is null) { return(null); } context.Entry(flightToUpdate).CurrentValues.SetValues(new { flight.Date, flight.FlightNo, flight.Status, flight.DepartureIata, flight.DepartureIcao, flight.DepartureGate, flight.DepartureDelay, flight.DepartureTerminal, flight.DepartureAirportName, flight.DepartureScheduled, flight.DepartureEstimated, flight.DepartureActual, flight.DestinationIata, flight.DestinationIcao, flight.DestinationGate, flight.DestinationDelay, flight.DestinationTerminal, flight.DestinationAirportName, flight.DestinationScheduled, flight.DestinationEstimated, flight.DestinationActual, flight.LastUpdated }); var result = await context.SaveChangesAsync(); if (result < 1) { return(null); } return(await context.Flight.SingleOrDefaultAsync(f => f.Id == flightToUpdate.Id)); }
public async Task <UserToken> UpdateUserTokenAsync(UserToken userToken) { var userTokenToUpdate = await context.UserToken.SingleOrDefaultAsync(ut => ut.Id == userToken.Id && ut.RefreshToken == userToken.RefreshToken); if (userTokenToUpdate is null) { return(null); } context.Entry(userTokenToUpdate).CurrentValues.SetValues(userToken); var result = await context.SaveChangesAsync(); if (result < 1) { return(null); } return(await context.UserToken.SingleOrDefaultAsync(ut => ut.Id == userToken.Id && ut.RefreshToken == userToken.RefreshToken)); }