コード例 #1
0
        /// <summary>
        /// Calls Man_Select_ById or Man_S_All to create a manufacturer
        /// </summary>
        /// <param name="id">The manufacturer id</param>
        /// <param name="hintAll">Precache all manufacturers if the requested manufacturer is not already cached</param>
        /// <returns>A car manufacturer</returns>
        private ICarManufacturer GetManufacturerFromId(int id, bool hintAll)
        {
            if (id == 0)
            {
                return(null);
            }

            CarManufacturer result    = null;
            Sproc           procedure = new Sproc("Man_S_All", DatabaseName);

            if (hintAll == false)
            {
                procedure.Name = "Man_Select_ById";
                procedure.Parameters.Add("@Id", SqlDbType.Int).Value = id;
            }

            using (SqlDataReader dataReader = procedure.ExecuteReader())
            {
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        CarManufacturer manufacturer = this.GetManufacturerFromDataReader(dataReader);
                        if (manufacturer.Id == id)
                        {
                            result = manufacturer;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Creates a car manufacturer from a data reader
        /// </summary>
        /// <param name="dataReader">The data reader</param>
        /// <returns>CarManufacturer representation of the data</returns>
        private CarManufacturer GetManufacturerFromDataReader(SqlDataReader dataReader)
        {
            CarManufacturer manufacturer = new CarManufacturer();

            manufacturer._id          = DataUtil.GetInt32(dataReader, "CARManId");
            manufacturer._name        = DataUtil.GetString(dataReader, "Manufacturer", null);
            manufacturer.LogoFileName = DataUtil.GetString(dataReader, "Logo", null);

            manufacturer._isDiscontinued = !dataReader.IsDBNull(dataReader.GetOrdinal("ManufacturerDiscontinued"));

            manufacturer.Url            = DataUtil.GetString(dataReader, "URLMain");
            manufacturer.PopularityRank = DataUtil.GetInt32(dataReader, "PopularityRank");

            manufacturer.HasReview   = DataUtil.GetBoolean(dataReader, "Review");
            manufacturer.HasTechData = DataUtil.GetBoolean(dataReader, "Tech");

            return(manufacturer);
        }
コード例 #3
0
        /// <summary>
        /// Gets a list of all manufacturers using GetManufacturerFromId and a cached list of IDs
        /// </summary>
        /// <returns>List of manufacturers</returns>
        public List <ICarManufacturer> GetManufacturers()
        {
            List <int> idList = this.GetManufacturerIds();
            List <ICarManufacturer> result = idList.ConvertAll <ICarManufacturer>(id => CarManufacturer.FromId(id));

            result.RemoveAll(m => m == null);

            return(result);
        }
コード例 #4
0
 /// <summary>
 /// Backs the base.Manufacturer property
 /// </summary>
 /// <returns></returns>
 protected override IManufacturer GetManufacturer()
 {
     return(CarManufacturer.FromId(_manufacturerId));
 }