コード例 #1
0
ファイル: Services.cs プロジェクト: GABAnich/HotelTelegramBot
        public static List <HotelRoom> GetAviableRooms(List <string> dates)
        {
            List <long> reservationIds      = ServicesHotelRoomReservedDate.GetReservationIds(dates);
            List <long> reservedHotelRoomId = ServicesReservation.GetReservedHotelRoomIds(reservationIds);

            return(ServicesHotelRoom.GetAviableHotelRooms(reservedHotelRoomId));
        }
コード例 #2
0
ファイル: Services.cs プロジェクト: GABAnich/HotelTelegramBot
        internal static async Task <Reservation> AddReservationAsync(long chatId, long hotelRoomTypeId, Reservation _r)
        {
            List <string> dates       = GetIntermediateDates(_r.DateOfArrival, _r.DateOfDeparture);
            long          hotelRoomId = GetHotelRoom(hotelRoomTypeId, dates).Id;

            _r.HotelRoomId = hotelRoomId;
            Reservation r = await ServicesReservation.AddReservationAsync(_r);

            await ServicesHotelRoomReservedDate.AddHotelRoomReservedDatesAsync(r.Id, dates);

            return(r);
        }
コード例 #3
0
ファイル: Services.cs プロジェクト: GABAnich/HotelTelegramBot
        public static List <Reservation> GetValidReservation(long chatId, DateTime lastDate)
        {
            List <Reservation> reservation = ServicesReservation.GetReservationByChatId(chatId);

            // Returns actual bookings
            for (int i = reservation.Count - 1; i > -1; i--)
            {
                if (IsAviableDate(reservation[i].DateOfDeparture, lastDate))
                {
                    reservation.RemoveAt(i);
                }
            }

            return(reservation);
        }
コード例 #4
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as CallbackQueryEventArgs).CallbackQuery.Data;
            Chat   chat      = (e as CallbackQueryEventArgs).CallbackQuery.Message.Chat;

            Reservation r = ServicesReservation.GetReservationById(int.Parse(userInput));

            if (r == null)
            {
                await ServicesMessageController.SendMessageAsync(chat, "Виберіть бронювання із списку", Keyboards.MainKeyboard);
            }
            await ServicesMessageController.SendMessageAsync(chat, "Знаття бронювання...");

            await DbServices.DeleteHotelRoomReservedDateByRoomIdAsync(r.Id);

            await ServicesReservation.DeleteReservationByIdAsync(r.Id);

            await ServicesMessageController.SendMessageAsync(chat, "Бронювання знято", Keyboards.ReturnMainMenu);

            responder.SetState(new MainMenu());
        }