Example #1
0
        internal OAirport GetOrDefault(string icao)
        {
            VatmapContext db = (VatmapContext)this.serviceProvider.GetService(typeof(VatmapContext));
            OAirport      ret;

            if (this.proxy.TryGetValue(icao, out ret) == false)
            {
                DAirport tmp = db.Airport.FirstOrDefault(q => q.Icao == icao);
                if (tmp != null)
                {
                    ret = new OAirport()
                    {
                        City    = tmp.City,
                        Country = tmp.Country,
                        ICAO    = tmp.Icao,
                        Name    = tmp.Name,
                        Gps     = new Gps()
                        {
                            Latitude = tmp.Latitude, Longitude = tmp.Longitude
                        }
                    };
                }
                else
                {
                    ret = new OAirport()
                    {
                        City    = "",
                        Country = "",
                        Name    = icao,
                        ICAO    = icao,
                        Gps     = null
                    };
                }
                this.proxy[ret.ICAO] = ret;
            }
            return(ret);
        }
Example #2
0
 public AirportDbProvider([FromServices] VatmapContext db)
 {
     this.db = db;
 }