public IEnumerable <Car> FindAvailableCarsForRental( DateTime requestedReservationStartDateTime, DateTime requestedReservationEndDateTime, string city) { var carService = new CarService(); carService.CalculatePriceForAvaliableCarsForRental(requestedReservationStartDateTime, requestedReservationEndDateTime, city); return(carService.result); }
/// <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); }
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); } }