Exemplo n.º 1
0
        public bool IsCheaperThan(Hotel anotherHotel, IHotelSearchCriteria hotelSearchCriteria)
        {
            decimal totalPriceOfThisHotel       = CalculateTotalPrice(hotelSearchCriteria.CostumerType, hotelSearchCriteria.Dates);
            decimal totalPriceOfTheAnotherHotel = anotherHotel.CalculateTotalPrice(hotelSearchCriteria.CostumerType, hotelSearchCriteria.Dates);

            if (totalPriceOfThisHotel == totalPriceOfTheAnotherHotel)
            {
                return(Rating > anotherHotel.Rating);
            }

            return(totalPriceOfThisHotel < totalPriceOfTheAnotherHotel);
        }
Exemplo n.º 2
0
        public string FindTheCheapestHotel(IHotelSearchCriteria hotelSearchCriteria)
        {
            Hotel cheapestHotel = null;

            foreach (var hotel in HotelRepository.GetAll())
            {
                if (cheapestHotel == null || hotel.IsCheaperThan(cheapestHotel, hotelSearchCriteria))
                {
                    cheapestHotel = hotel;
                }
            }

            return(cheapestHotel.Name);
        }
        public string Do(string serializedCriteria)
        {
            IHotelSearchCriteria hotelSearchCriteria = HotelSearchCriteria.CreateFromSerializedCriteria(serializedCriteria);

            return(FindTheCheapestHotel.Do(hotelSearchCriteria));
        }