private async Task <bool> SaveAirlineToDbAsync(string id, string name) { try { _context.Airlines.Add(new Airline { Id = id, Name = name, CreatedTime = DateTime.Now, UpdatedTime = DateTime.Now, }); int x = await _context.SaveChangesAsync(); return(x > 0); } catch (Exception ex) { var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); var fullMethodName = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; //_LogService.LogException(ex, fullMethodName); return(false); } }
private async Task <bool> SaveAirportToDbAsync(AirportRS airportRs) { try { var city = await RetrieveAirportFromDbAsync(airportRs.Code); if (city == null) { Country country = await RetrieveCountryFromDbAsync(airportRs.CountryCode); country.Airports = new List <Airport>(); country.Airports.Add(new Airport { Id = airportRs.Code, Name = airportRs.Name, Longitude = (float)airportRs.Longitude, Latitude = (float)airportRs.Latitude, //CountryCode = airportRs.CountryCode, CityName = airportRs.CityName, CreatedTime = DateTime.Now, UpdatedTime = DateTime.Now, }); int x = await _context.SaveChangesAsync(); return(x > 0); } else { return(true); } } catch (Exception ex) { var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); var fullMethodName = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; _LogService.LogException(ex, fullMethodName); return(false); } }