public static void BookingNumber(BookingLog note, Room room, User user, Hotel hotel)
        {
            //note.RoomNumber = room.Number;
            //note.GuestName = user.Login;
            //note.HotelName = hotel.Name;
            user.Id = AccountsTableDataService.GetAccountId(user.Login);

            Console.Write("Please ender data:\n" +
                          "ArrivalDate (dd.mm.yyyy): ");
            note.ArrivalDate = DateTime.Parse(Console.ReadLine());

            Console.Write("DepartureDate (dd.mm.yyyy): ");
            note.DepartureDate = DateTime.Parse(Console.ReadLine());

            Console.WriteLine("\n1) To book \n2) To Pay");
            int choice = int.Parse(Console.ReadLine());

            if (choice == 1)
            {
                note.Payment = 0;
            }
            else if (choice == 2)
            {
                note.Payment = (note.DepartureDate - note.ArrivalDate).TotalDays * RoomsTableDataService.GetRoomPrice(room.Id);
            }

            BookingLogTableDataService.AddNote(note, room.Id, user.Id, hotel.Id);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            User user        = new User();
            var  dataService = new AccountsTableDataService();

            while (true)
            {
                System.Console.Clear();
                System.Console.Write("1) Registration \n" +
                                     "2) Authorization \n" +
                                     "3) Exit \n" +
                                     "Choice: ");
                int choice = int.Parse(System.Console.ReadLine());

                if (choice == 1)
                {
                    Registration.SignUp(user, dataService);
                }
                else if (choice == 2)
                {
                    Authorization.SignIn(user);

                    List <Hotel> hotels = HotelsTableDataService.GetAllHotels();
                    for (int i = 0; i < hotels.Count; i++)
                    {
                        System.Console.WriteLine($"{i+1}) {hotels[i].Name}");
                    }
                    System.Console.Write("Choice: ");
                    int hotelPosition = int.Parse(System.Console.ReadLine());

                    List <Room> rooms = RoomsTableDataService.GetAvailableRooms(hotels[hotelPosition - 1].Id);
                    System.Console.WriteLine("{0,7} | {1,15} | {2,10}", "№", "Category", "Price");

                    for (int i = 0; i < rooms.Count; i++)
                    {
                        System.Console.Write($"{i+1}) ");
                        rooms[i].Show(i + 1);
                    }
                    System.Console.Write("Please, make your choice: ");
                    int roomPosition = int.Parse(System.Console.ReadLine());

                    BookingLog note = new BookingLog();

                    Reservation.BookingNumber(note, rooms[roomPosition - 1], user, hotels[hotelPosition - 1]);
                    System.Console.ReadLine();
                }
                else
                {
                    System.Environment.Exit(0);
                }
            }
        }