Пример #1
0
        public Fuel GetFuelByTypeAndGrade(FuelType fuelType, FuelGrade fuelGrade)
        {
            var fuel = Context.Fuels.SingleOrDefault(f => f.FuelType == fuelType && f.FuelGrade == fuelGrade);

            if (fuel == null)
            {
                fuel = new Fuel()
                {
                    FuelType = fuelType, FuelGrade = fuelGrade, FuelName = fuelType.ToString() + fuelGrade.ToString()
                }
            }
            ;

            return(fuel);
        }
    }
Пример #2
0
        private void UpdateStationPrice(Station station, double priceValue, FuelType fuelType, FuelGrade fuelGrade)
        {
            var fuelPrice = station.FuelPrices.SingleOrDefault(x => x.Fuel?.FuelType == fuelType && x.Fuel?.FuelGrade == fuelGrade);

            if (fuelPrice == null)
            {
                fuelPrice = new FuelPrice()
                {
                    Fuel  = _stationRepo.GetFuelByTypeAndGrade(fuelType, fuelGrade),
                    Price = new Price()
                };

                station.FuelPrices.Add(fuelPrice);
            }

            fuelPrice.Price.PriceValue = priceValue;
        }