public int?GetMaxDieselAnnualFuelCost(out int dieselPencePerlitre)
        {
            if (!this.HasDieselDerivatives)
            {
                dieselPencePerlitre = 0;
                return(null);
            }

            ICarDerivative lowestMpgDieselDerivative = (from ICarDerivative der in this.Derivatives
                                                        where (der.FuelType == "D" && der.MilesPerGallon > 0)
                                                        orderby der.MilesPerGallon
                                                        select der).FirstOrDefault() as ICarDerivative;

            if (lowestMpgDieselDerivative == null)
            {
                dieselPencePerlitre = 0;
                return(null);
            }

            double milesPerGallon = Convert.ToDouble(lowestMpgDieselDerivative.MilesPerGallon);

            dieselPencePerlitre = Convert.ToInt32(fuelPriceProvider.DieselPrice);

            return(this.GetAnnualFuelCost(milesPerGallon, dieselPencePerlitre));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the plates by derivative id.
        /// </summary>
        /// <param name="derivative">The derivative.</param>
        /// <param name="section">The section.</param>
        /// <returns>List of year plates</returns>
        public List <IYearPlate> GetPlatesByDerivative(ICarDerivative derivative, CarValuationSection section)
        {
            int sectionYearFromPlateId = GetFromYearPlateIdForSection(section);
            int sectionYearToPlateId   = GetToYearPlateIdForSection(section);

            if (derivative.FromYearPlate == null || derivative.ToYearPlate == null)
            {
                return(null);
            }

            int plateFrom = derivative.FromYearPlate.Id;
            int plateTo   = derivative.ToYearPlate.Id;

            if (sectionYearFromPlateId > plateFrom)
            {
                plateFrom = sectionYearFromPlateId;
            }

            if (sectionYearToPlateId < plateTo)
            {
                plateTo = sectionYearToPlateId;
            }

            return(yearPlateProvider.GetRange(plateFrom, plateTo));
        }
        public int?GetMaxUnleadedAnnualFuelCost(out int unleadedPencePerLitre)
        {
            ICarDerivative lowestMpgUnleadedDerivative = (from ICarDerivative der in this.Derivatives
                                                          where (der.FuelType == "P" && der.MilesPerGallon > 0)
                                                          orderby der.MilesPerGallon
                                                          select der).FirstOrDefault() as ICarDerivative;

            if (lowestMpgUnleadedDerivative == null)
            {
                unleadedPencePerLitre = 0;
                return(null);
            }

            double milesPerGallon = Convert.ToDouble(lowestMpgUnleadedDerivative.MilesPerGallon);

            unleadedPencePerLitre = Convert.ToInt32(fuelPriceProvider.PetrolPrice);

            return(this.GetAnnualFuelCost(milesPerGallon, unleadedPencePerLitre));
        }