/// <summary>
        /// Returns a list of the aircraft available for the user
        /// </summary>
        /// <param name="restriction">which set of aircraft to get?</param>
        /// <param name="idModel">The model id to restrict on (only applies for AllmakeModel)</param>
        /// <returns>An array of aircraft</returns>
        public Aircraft[] GetAircraftForUser(AircraftRestriction restriction, int idModel = -1)
        {
            // If no authenticated user, return immediately - don't hit the database!
            // Should never happen.
            if (String.IsNullOrEmpty(User) && restriction == AircraftRestriction.UserAircraft)
            {
                return(new Aircraft[0]);
            }

            Aircraft[] rgAircraft = CachedAircraft;

            if (rgAircraft != null && restriction == AircraftRestriction.UserAircraft) // don't cache in admin mode
            {
                return(rgAircraft);
            }

            string szRestrict     = "";
            string szFlags        = "0";
            string szPrivateNotes = "''";
            string szDefaultImage = "''";

            switch (restriction)
            {
            case AircraftRestriction.AllAircraft:
            default:
                break;

            case AircraftRestriction.AllSims:
                szRestrict = String.Format(CultureInfo.InvariantCulture, " WHERE aircraft.InstanceType <> {0} {1}", (int)AircraftInstanceTypes.RealAircraft, idModel > 0 ? " AND aircraft.idModel = ?idModel " : String.Empty);
                break;

            case AircraftRestriction.UserAircraft:
                szRestrict     = "INNER JOIN useraircraft ON aircraft.idAircraft = useraircraft.idAircraft WHERE useraircraft.userName = ?UserName";
                szFlags        = "useraircraft.flags";
                szPrivateNotes = "useraircraft.PrivateNotes";
                szDefaultImage = "DefaultImage";
                break;

            case AircraftRestriction.AllMakeModel:
                szRestrict = " WHERE aircraft.idModel = ?idModel ";
                break;
            }

            string    szQ        = String.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["AircraftForUserCore"].ToString(), szFlags, szDefaultImage, szPrivateNotes, szRestrict);
            ArrayList alAircraft = new ArrayList();

            DBHelper dbh = new DBHelper(szQ);

            if (!dbh.ReadRows(
                    (comm) =>
            {
                comm.Parameters.AddWithValue("UserName", User);
                comm.Parameters.AddWithValue("idModel", idModel);
            },
                    (dr) => { alAircraft.Add(new Aircraft(dr)); }))
            {
                throw new MyFlightbookException("Error getting aircraft for user: "******"\r\n" + dbh.LastError);
            }

            rgAircraft = (Aircraft[])alAircraft.ToArray(typeof(Aircraft));

            if (restriction == AircraftRestriction.UserAircraft)
            {
                CachedAircraft = rgAircraft;
            }

            return(rgAircraft);
        }
 /// <summary>
 /// Returns a list of the aircraft available for the user
 /// </summary>
 /// <param name="restriction">which set of aircraft to get?</param>
 /// <param name="idModel">The model id to restrict on (only applies for AllmakeModel)</param>
 /// <returns>An enumerable of aircraft</returns>
 public IEnumerable <Aircraft> GetAircraftForUser(AircraftRestriction restriction, int idModel = -1)
 {
     return(GetAircraftForUserInternal(restriction, idModel));
 }