コード例 #1
0
        public MainWindowViewModel()
        {
            AddClientCommand    = new DelegateCommand(OnAddClientCommand);
            DeleteClientCommand = new DelegateCommand(OnDeleteClientCommand, () => Client != null);
            UpdateClientCommand = new DelegateCommand(OnUpdateClientCommand, () => Client != null);

            AddReservationCommand    = new DelegateCommand(OnAddReservationCommand);
            DeleteReservationCommand = new DelegateCommand(OnDeleteReservationCommand, () => Reservation != null);
            UpdateReservationCommand = new DelegateCommand(OnUpdateReservationCommand, () => Reservation != null);

            AddRoomCommand    = new DelegateCommand(OnAddRoomCommand);
            DeleteRoomCommand = new DelegateCommand(OnDeleteRoomCommand, () => Room != null);
            UpdateRoomCommand = new DelegateCommand(OnUpdateRoomCommand, () => Room != null);

            AddInvoiceCommand    = new DelegateCommand(OnAddInvoiceCommand);
            DeleteInvoiceCommand = new DelegateCommand(OnDeleteInvoiceCommand, () => Invoice != null);
            UpdateInvoiceCommand = new DelegateCommand(OnUpdateInvoiceCommand, () => Invoice != null);

            SearchCommand = new DelegateCommand(OnSearchCommand, () => !string.IsNullOrWhiteSpace(SearchText));

            SearchTypeList = new List <string>();
            SearchTypeList.Add(NameSearchType);
            SearchTypeList.Add(PhoneSearchType);
            SearchTypeList.Add(PNSearchType);
            SearchTypeList.Add(EmailSearchType);

            hotelRepository = HotelRepository.Instance;
        }
コード例 #2
0
        /// Overriding the Equals() method
        /// To compare the objects returned from the methods of
        /// the HotelAdapter class in the unit tests
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is HotelRepository))
            {
                return(false);
            }
            HotelRepository hotelRepository = (HotelRepository)obj;

            return(this.hotelName == hotelRepository.hotelName && this.rate == hotelRepository.rate && this.hotelRating == hotelRepository.hotelRating);
        }
コード例 #3
0
        /// Method defined to return the best rated hotel
        /// for a given date range
        public HotelRepository GetBestRatedHotel(string customerType, string dt1, string dt2)
        {
            CustomerType    type = GetCustomerType(customerType);
            HotelRepository hotel = new HotelRepository();
            List <int>      hotelRatings = new List <int>();
            DateTime        date1 = Convert.ToDateTime(dt1);
            DateTime        date2 = Convert.ToDateTime(dt2);
            int             total1 = 0, total2 = 0, total3 = 0;

            for (DateTime date = date1; date <= date2; date = date.AddDays(1))
            {
                hotel  = GetRate(type, date, LAKEWOOD);
                total1 = total1 + hotel.rate;
                hotelRatings.Add(hotel.hotelRating);
            }
            for (DateTime date = date1; date <= date2; date = date.AddDays(1))
            {
                hotel  = GetRate(type, date, BRIDGEWOOD);
                total2 = total2 + hotel.rate;
                hotelRatings.Add(hotel.hotelRating);
            }
            for (DateTime date = date1; date <= date2; date = date.AddDays(1))
            {
                hotel  = GetRate(type, date, RIDGEWOOD);
                total3 = total3 + hotel.rate;
                hotelRatings.Add(hotel.hotelRating);
            }
            int maximumRating = GetMaximum(hotelRatings);

            if (maximumRating == LAKEWOOD_RATINGS)
            {
                return(new HotelRepository(total1, LAKEWOOD, LAKEWOOD_RATINGS));
            }
            else if (maximumRating == BRIDGEWOOD_RATINGS)
            {
                return(new HotelRepository(total2, BRIDGEWOOD, BRIDGEWOOD_RATINGS));
            }
            else
            {
                return(new HotelRepository(total3, RIDGEWOOD, RIDGEWOOD_RATINGS));
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Hotel Reservation");
            Console.WriteLine("--------------------------");
            Console.WriteLine("Enter the customer type: Regular or Reward");
            string type = Console.ReadLine();

            Console.WriteLine("Enter the check in date: for example 10Jan2020");
            string date1 = Console.ReadLine();

            Console.WriteLine("Enter the check out date");
            string          date2   = Console.ReadLine();
            HotelAdapter    adapter = new HotelAdapter();
            HotelRepository result  = adapter.GetCheapestHotel(type, date1, date2);

            Console.WriteLine("Cheapest best rated hotel for you is: ");
            Console.WriteLine("Hotel name: " + result.hotelName);
            Console.WriteLine("Price: " + result.rate);
            Console.WriteLine("Rating:" + result.hotelRating);
        }
コード例 #5
0
 public ReservationWindowViewModel()
 {
     this.Reservation = new Reservation();
     hotelRepository  = HotelRepository.Instance;
 }
コード例 #6
0
        /// Gets the cheapest hotel for a given date range
        public HotelRepository GetCheapestHotel(string customerType, string dt1, string dt2)
        {
            CustomerType type = GetCustomerType(customerType);
            //Defining a list to store the list of cheapest hotel(s)
            List <HotelRepository> hotels = new List <HotelRepository>();
            HotelRepository        hotel  = new HotelRepository();
            DateTime date1 = Convert.ToDateTime(dt1);
            DateTime date2 = Convert.ToDateTime(dt2);
            int      total1 = 0, total2 = 0, total3 = 0;
            TimeSpan duration = date2.Subtract(date1);
            int      length   = Convert.ToInt32(duration.TotalDays);

            for (DateTime date = date1; date <= date2; date = date.AddDays(1))
            {
                hotel  = GetRate(type, date, LAKEWOOD);
                total1 = total1 + hotel.rate;
            }

            for (DateTime date = date1; date <= date2; date = date.AddDays(1))

            {
                hotel  = GetRate(type, date, BRIDGEWOOD);
                total2 = total2 + hotel.rate;
            }

            for (DateTime date = date1; date <= date2; date = date.AddDays(1))

            {
                hotel  = GetRate(type, date, RIDGEWOOD);
                total3 = total3 + hotel.rate;
            }
            int minTotalRate = GetMinimum(total1, total2, total3);
            int minRate      = minTotalRate / length;

            if (minTotalRate == total1)
            {
                hotels.Add(new HotelRepository(minRate, LAKEWOOD, LAKEWOOD_RATINGS));
            }
            if (minTotalRate == total2)
            {
                hotels.Add(new HotelRepository(minRate, BRIDGEWOOD, BRIDGEWOOD_RATINGS));
            }
            if (minTotalRate == total3)
            {
                hotels.Add(new HotelRepository(minRate, RIDGEWOOD, RIDGEWOOD_RATINGS));
            }
            int        hotelRate    = 0;
            List <int> hotelRatings = new List <int>();

            foreach (HotelRepository elements in hotels)
            {
                hotelRatings.Add(elements.hotelRating);
            }
            hotelRate = GetMaximum(hotelRatings);
            switch (hotelRate)
            {
            case LAKEWOOD_RATINGS: hotelName = LAKEWOOD;
                break;

            case BRIDGEWOOD_RATINGS: hotelName = BRIDGEWOOD;
                break;

            case RIDGEWOOD_RATINGS: hotelName = RIDGEWOOD;
                break;

            default: break;
            }
            return(new HotelRepository(minRate, hotelName, hotelRate));
        }