Exemplo n.º 1
0
 /// <summary>
 /// Add one record to the database
 /// </summary>
 /// <param name="rec">A new record</param>
 public string Add(icaoActRec rec)
 {
     if (rec != null)
     {
         return(m_db.Add(rec));
     }
     return("");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a new Icao Record from given Jason
        /// </summary>
        /// <param name="native">The record as Jason fragment</param>
        private static icaoActRec FromNative(string native)
        {
            JsonRecord jRec = JsonParser.Decompose(native);

            if (jRec?.Count > 0)
            {
                var icao = !jRec.Values[0].ContainsKey("Designator") ? "" : jRec.Values[0]["Designator"].ToUpperInvariant( );
                var desc = !jRec.Values[0].ContainsKey("Description") ? "" : jRec.Values[0]["Description"].ToUpperInvariant( );
                var wtc  = !jRec.Values[0].ContainsKey("WTC") ? "" : jRec.Values[0]["WTC"].ToUpperInvariant( );
                var mfn  = !jRec.Values[0].ContainsKey("ModelFullName") ? "" : jRec.Values[0]["ModelFullName"];
                var mcod = !jRec.Values[0].ContainsKey("ManufacturerCode") ? "" : jRec.Values[0]["ManufacturerCode"].ToUpperInvariant( );
                var acd  = !jRec.Values[0].ContainsKey("AircraftDescription") ? "" : jRec.Values[0]["AircraftDescription"];
                var ec   = !jRec.Values[0].ContainsKey("EngineCount") ? "" : jRec.Values[0]["EngineCount"];
                var et   = !jRec.Values[0].ContainsKey("EngineType") ? "" : jRec.Values[0]["EngineType"];

                var iRec = new icaoActRec(icao.ToUpperInvariant( ), desc, wtc, mfn, mcod, acd, ec, et);
                return(iRec);
            }
            else
            {
                return(null);
            }
        }