private static void Populate() { Sproc sp = new Sproc("Fam_S", "ParkersCAR"); using (SqlDataReader dr = sp.ExecuteReader()) { if (dr != null && dr.HasRows) { _list = new Dictionary <int, CarFamily>(); CarFamily none = new CarFamily(); none._name = ""; none._id = 0; _list.Add(0, none); while (dr.Read()) { CarFamily newFamily = new CarFamily(dr); _list[newFamily.Id] = newFamily; } } } }
/// <summary> /// Creates a car model from a data reader /// </summary> /// <param name="dataReader">The data reader</param> /// <returns>CarModel representation of the data</returns> private CarModel GetModelFromDataReader(SqlDataReader dataReader) { CarModel model = new CarModel(); model.Id = DataUtil.GetInt32(dataReader, "CARModId"); model.RangeId = DataUtil.GetInt32(dataReader, "CARRanId"); model.GenericBodyStyle = DataUtil.GetString(dataReader, "BodyGeneric"); model.OriginalBodyStyle = DataUtil.GetString(dataReader, "BodyOriginal"); model.BodyStyle = DataUtil.GetString(dataReader, "Model"); if (model.BodyStyle == String.Empty) { model.BodyStyle = model.OriginalBodyStyle; } model.PopularityRank = DataUtil.GetInt32(dataReader, "PopularityRank"); model.Popularity = DataUtil.GetDouble(dataReader, "Popularity"); model.Name = (string)dataReader["RangeModel"]; model.NameWithYears = (string)dataReader["RangeModelYear"]; model.IntroducedYear = (int)dataReader["ModelIntroduced"]; model.DiscontinuedYear = DataUtil.GetInt32(dataReader, "ModelDiscontinued", Int32.MaxValue); IYearPlateProvider yearPlateProvider = new YearPlateProvider(); model.FromYearPlate = yearPlateProvider.FromId(DataUtil.GetInt32(dataReader, "FromYearPlateId")); model.ToYearPlate = yearPlateProvider.FromId(DataUtil.GetInt32(dataReader, "ToYearPlateId")); model.OwnerReviewCount = DataUtil.GetInt32(dataReader, "UserReview") + DataUtil.GetInt32(dataReader, "UserReviewArchive"); model.HasReview = DataUtil.GetBoolean(dataReader, "Review"); model.HasTechData = DataUtil.GetBoolean(dataReader, "Tech"); model.CAPBodyStyleId = Convert.ToString(dataReader["CAPBodyStyleId"]); model.CAPRanId = Convert.ToString(dataReader["CAPRanId"]); model._imageId = DataUtil.GetInt32(dataReader, "CAPImageId"); model.MinPriceNew = DataUtil.GetInt32(dataReader, "NewMin"); model.MaxPriceNew = DataUtil.GetInt32(dataReader, "NewMax"); model.MinPriceUsed = DataUtil.GetInt32(dataReader, "UsedMin"); model.MaxPriceUsed = DataUtil.GetInt32(dataReader, "UsedMax"); model.AdultSeats = DataUtil.GetInt32(dataReader, "SuitableAdults"); model.SeatsWithLuggage = DataUtil.GetInt32(dataReader, "SuitableAdultsWithLuggage"); model._minPriceFRV12 = DataUtil.GetInt32(dataReader, "FRV12Min"); model._maxPriceFRV12 = DataUtil.GetInt32(dataReader, "FRV12Max"); model._minPriceFRV36 = DataUtil.GetInt32(dataReader, "FRV36Min"); model._maxPriceFRV36 = DataUtil.GetInt32(dataReader, "FRV36Max"); model._MinCo2 = DataUtil.GetInt32(dataReader, "CO2Min"); model._MaxCo2 = DataUtil.GetInt32(dataReader, "CO2Max"); model._maxAnnualFuelCost = DataUtil.GetInt32(dataReader, "AnnualFuelCostMax"); model._minAnnualFuelCost = DataUtil.GetInt32(dataReader, "AnnualFuelCostMin"); model._maxVedFull = DataUtil.GetDecimal(dataReader, "VEDFullMax"); model._minVedFull = DataUtil.GetDecimal(dataReader, "VEDFullMin"); model._minLuggageCapacity = DataUtil.GetInt32(dataReader, "LuggageCapacityMin"); model._family = CarFamily.FromId(DataUtil.GetInt32(dataReader, "CARFamId")); model._otherModelWithSameBodyOriginal = (DataUtil.GetInt32(dataReader, "ModelsWithSameBodyOriginal") > 1); model._relatedModelIds.Add(DataUtil.GetInt32(dataReader, "ComputedAlternativeModelWithinRange")); model._relatedModelIds.Add(DataUtil.GetInt32(dataReader, "ComputedAlternativeModel1")); model._relatedModelIds.Add(DataUtil.GetInt32(dataReader, "ComputedAlternativeModel2")); model._relatedModelIds.Add(DataUtil.GetInt32(dataReader, "ComputedAlternativeModel3")); model.UrlVariantIndex = DataUtil.GetInt32(dataReader, "ModelVariantIndex", 0); model.IsLatest = DataUtil.GetBoolean(dataReader, "IsLatest"); return(model); }