示例#1
0
 //finished
 private void RunRemoveTownPage()
 {
     Display.PrintRemoveTownPage();
     Services.CountryService countryService = new Services.CountryService();
     try
     {
         string countryName = Console.ReadLine();
         countryService.GetCountryByName(countryName);
         Console.WriteLine("Now enter name of town:");
         string townName = Console.ReadLine();
         Services.VoucherService voucherService = new Services.VoucherService();
         Services.HotelService   hotelService   = new Services.HotelService();
         Services.TownService    townService    = new Services.TownService();
         townService.GetTownByName(countryName, townName);
         voucherService.DeleteVoucherByTown(townName);
         hotelService.DeleteHotelByTown(townName);
         townService.DeleteTown(countryName, townName);
         Display.RemovedTownMessage(countryName, townName);
     }
     catch (Exception ex)
     {
         Display.PrintErrorScreen();
         Console.WriteLine(ex.Message);
         Console.WriteLine(Display.GoBackMessage());
     }
     Console.ReadKey(true);
 }
示例#2
0
        //finished
        private void RunListTouristsByHotel()
        {
            Display.PrintListTouristsByHotel();
            string country = Console.ReadLine();

            Services.CountryService countryService = new Services.CountryService();
            Services.TownService    townService    = new Services.TownService();
            Services.HotelService   hotelService   = new Services.HotelService();
            Services.VoucherService voucherService = new Services.VoucherService();
            try
            {
                countryService.GetCountryByName(country);
                Console.WriteLine("Enter name of town:");
                string town = Console.ReadLine();
                townService.GetTownByName(country, town);
                Console.WriteLine("Enter name of Hotel:");
                string hotel = Console.ReadLine();
                Display.ListTouristsByHotel(country, town, hotel);
            }
            catch (Exception ex)
            {
                Display.PrintErrorScreen();
                Console.WriteLine(ex.Message);
                Console.WriteLine(Display.GoBackMessage());
            }
            Console.ReadKey(true);
        }
示例#3
0
        public static void ListTouristsByHotel(string countryName, string townName, string hotelName)
        {
            Console.Clear();
            Console.WriteLine(Header());
            Console.WriteLine(ListTouristsMenu());
            Console.WriteLine($"Tourists in {hotelName}:" + Environment.NewLine);

            Services.VoucherService voucherService = new Services.VoucherService();
            foreach (Tourist tourist in voucherService.GetAllTouristsByHotel(countryName, townName, hotelName))
            {
                Console.WriteLine(tourist.ToString());
            }

            Console.WriteLine(GoBackMessage());
        }
示例#4
0
        //cursed - do not touch
        private void RunAddVoucher()
        {
            Display.PrintAddVoucherPage();
            Services.TouristService touristService = new Services.TouristService();
            Services.HotelService   hotelService   = new Services.HotelService();
            Services.VoucherService voucherService = new Services.VoucherService();
            try
            {
                Console.WriteLine("Enter tourist's ID:");
                int touristID = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter name of country for hotel:");
                string countryName = Console.ReadLine();
                Console.WriteLine("Enter name of town for hotel:");
                string townName = Console.ReadLine();
                Console.WriteLine("Enter name of hotel:");
                string hotelName = Console.ReadLine();
                Console.WriteLine("Enter days of trip:");
                int daysOfTrip = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter cancellation period (in days):");
                int cancellationPeriod = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter start date (yyyy mm dd):");
                string[] date1     = Console.ReadLine().Split().ToArray();
                DateTime startDate = new DateTime(int.Parse(date1[0]), int.Parse(date1[1]), int.Parse(date1[2]));
                Console.WriteLine("Enter end date (yyyy mm dd):");
                string[] date2   = Console.ReadLine().Split().ToArray();
                DateTime endDate = new DateTime(int.Parse(date2[0]), int.Parse(date2[1]), int.Parse(date2[2]));

                voucherService.CreateVoucher(touristService.GetTouristById(touristID),
                                             voucherService.FindHotelByName(townName, hotelName, voucherService.FindTownByName(countryName, townName)),
                                             daysOfTrip,
                                             voucherService.CalculateTripPriceForVoucher(daysOfTrip, voucherService.FindHotelByName(townName, hotelName, voucherService.FindTownByName(countryName, townName)).PricePerNight),
                                             cancellationPeriod, startDate, endDate);
                Display.AddedVoucherMessage();
            }
            catch (Exception ex)
            {
                Display.PrintErrorScreen();
                Console.WriteLine(ex.Message);
                Console.WriteLine(Display.GoBackMessage());
            }
            Console.ReadKey(true);
        }
示例#5
0
 //finished
 private void RunRemoveCountryPage()
 {
     Display.PrintRemoveCountryPage();
     Services.CountryService countryService = new Services.CountryService();
     try
     {
         string countryName = Console.ReadLine();
         countryService.GetCountryByName(countryName);
         Services.VoucherService voucherService = new Services.VoucherService();
         voucherService.DeleteVoucherByCountry(countryName);
         Services.HotelService hotelService = new Services.HotelService();
         hotelService.DeleteHotelByCountry(countryName);
         Services.TownService townService = new Services.TownService();
         countryService.DeleteCountry(countryName);
         Display.RemovedCountryMessage(countryName);
     }
     catch (Exception ex)
     {
         Display.PrintErrorScreen();
         Console.WriteLine(ex.Message);
         Console.WriteLine(Display.GoBackMessage());
     }
     Console.ReadKey(true);
 }