コード例 #1
0
        public IEnumerable <Car> FindAvailableCarsForRental(
            DateTime requestedReservationStartDateTime, DateTime requestedReservationEndDateTime, string city)
        {
            var carService = new CarService();

            carService.CalculatePriceForAvaliableCarsForRental(requestedReservationStartDateTime,
                                                               requestedReservationEndDateTime, city);

            return(carService.result);
        }
コード例 #2
0
 /// <summary>
 /// Finding all avaliable cars for rental form a particualr city like city="Wien"
 /// </summary>
 /// <param name="customer"></param>
 /// <param name="requestedReservationStartDateTime"></param>
 /// <param name="requestedReservationEndDateTime"></param>
 /// <param name="city"></param>
 /// <returns></returns>
 public Dictionary <CarModel, decimal> FindAvailableCarsForRental(CustomerModel customer, DateTime requestedReservationStartDateTime, DateTime requestedReservationEndDateTime, string city)
 {
     // Declear calculatePriceForAvaliableCars
     calculatePriceForAvaliableCars = new CarService();
     // Call calculatePriceForAvaliableCars.CalculatePriceForAvaliableCarsForRental
     try
     {
         calculatePriceForAvaliableCars.CalculatePriceForAvaliableCarsForRental(customer, requestedReservationStartDateTime, requestedReservationEndDateTime, city);
     }
     catch
     {
         throw new ArgumentNullException();
     }
     // Return CalculatePriceForAvaliableCarsForRental.Results
     return(calculatePriceForAvaliableCars.result.Count > 0 ? calculatePriceForAvaliableCars.result : null);
 }
コード例 #3
0
        public void CalculatePriceForAvaliableCarsForRental(
            DateTime requestedReservationStartDateTime, DateTime requestedReservationEndDateTime,
            string city)
        {
            var carService            = new CarService();
            var resultOfAvailableCars = new Dictionary <Car, decimal>();
            var calculatePrice        = 0.0m;

            availableCars = carService.FindAvailableCarsForRental(requestedReservationStartDateTime,
                                                                  requestedReservationEndDateTime, city);

            foreach (var availableCar in availableCars)
            {
                if (availableCar.Category == Car.Small)
                {
                    CarConsumerCategory(requestedReservationStartDateTime, requestedReservationEndDateTime);
                }
                else if (availableCar.Category == Car.Medium)
                {
                    CarConsumerCategory(requestedReservationStartDateTime, requestedReservationEndDateTime);
                }
                else if (availableCar.Category == Car.Large)
                {
                    CarConsumerCategory(requestedReservationStartDateTime, requestedReservationEndDateTime);
                }
                else if (availableCar.Category == Car.Luxury)
                {
                    CarConsumerCategory(requestedReservationStartDateTime, requestedReservationEndDateTime);
                }
                else
                {
                    calculatePrice = 0.0m;
                }

                resultOfAvailableCars.Add(availableCar, calculatePrice);
            }
        }