예제 #1
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as CallbackQueryEventArgs).CallbackQuery.Data;
            Chat   chat      = (e as CallbackQueryEventArgs).CallbackQuery.Message.Chat;

            if (!Validator.CheckNumber(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadNumber);

                return;
            }

            long          roomTypeId = int.Parse(userInput);
            HotelRoomType roomType   = ServicesHotelRoomType.GetHotelRoomTypeById(roomTypeId);
            List <string> photos     = DbServices.GetHotelRoomTypeImagesUrl(roomTypeId);

            if (roomType == null)
            {
                await ServicesMessageController.SendMessageAsync(
                    chat, "Такого типу номеру не існує", Keyboards.ReturnMainMenu);

                return;
            }

            string message = ViewRoomType.GetTextAboutRoomType(roomType);
            await ServicesMessageController.SendPhotosAsync(chat.Id, photos);

            await ServicesMessageController.SendMessageAsync(chat, message, Keyboards.ReturnMainMenu);

            responder.SetState(new HotelRoom_0());
        }
예제 #2
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as CallbackQueryEventArgs).CallbackQuery.Data;
            Chat   chat      = (e as CallbackQueryEventArgs).CallbackQuery.Message.Chat;

            if (!Validator.CheckNumber(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadNumber);

                return;
            }
            long id            = long.Parse(userInput);
            var  listRoomTypes = DbServices.GetAviableRoomTypes(arrival, departure, int.Parse(adults), int.Parse(children));

            if (ServicesHotelRoomType.GetHotelRoomTypeById(id) == null ||
                !listRoomTypes.Exists(t => t.Id == id))
            {
                await ServicesMessageController.SendMessageAsync(
                    chat, "Оберіть тип номеру", Keyboards.ReturnMainMenu);

                return;
            }
            ;

            responder.userTempData["HotelRoomTypeId"] = userInput;
            responder.SetState(new BookRoom_05());
        }
예제 #3
0
        internal static IReplyMarkup GetReservationsMenu(List <Reservation> listReservation)
        {
            List <List <InlineKeyboardButton> > keyboards = new List <List <InlineKeyboardButton> >();

            foreach (Reservation r in listReservation)
            {
                HotelRoom     room     = ServicesHotelRoom.GetHotelRoomById(r.HotelRoomId);
                HotelRoomType roomType = ServicesHotelRoomType.GetHotelRoomTypeById(room.HotelRoomTypeId);
                keyboards.Add(new List <InlineKeyboardButton>()
                {
                    InlineKeyboardButton.WithCallbackData(
                        $"{roomType.Name}: {r.DateOfArrival}-{r.DateOfDeparture}",
                        $"{r.Id}"
                        )
                });
            }
            return(new InlineKeyboardMarkup(keyboards));
        }
예제 #4
0
        public override async void OnStateChange(Chat chat)
        {
            await ServicesMessageController.SendMessageAsync(chat, "Очікування бронювання");

            responder.userTempData.TryGetValue("HotelRoomTypeId", out string hotelRoomTypeId);
            responder.userTempData.TryGetValue("DateOfArrival", out string arrival);
            responder.userTempData.TryGetValue("DateOfDeparture", out string departure);
            responder.userTempData.TryGetValue("SecondName", out string secondName);
            responder.userTempData.TryGetValue("FirstName", out string firstName);
            responder.userTempData.TryGetValue("MiddleName", out string middleName);
            responder.userTempData.TryGetValue("Number", out string number);
            responder.userTempData.TryGetValue("Email", out string email);
            responder.userTempData.TryGetValue("NumberOfAdults", out string adults);
            responder.userTempData.TryGetValue("NumberOfChildren", out string children);

            Reservation reservation = new Reservation()
            {
                IdUserChat       = chat.Id,
                SecondName       = secondName,
                FirstName        = firstName,
                MiddleName       = middleName,
                Number           = number,
                Email            = email,
                DateOfArrival    = arrival,
                DateOfDeparture  = departure,
                NumberOfAdults   = int.Parse(adults),
                NumberOfChildren = int.Parse(children)
            };

            Reservation r = await DbServices.AddReservationAsync(chat.Id, int.Parse(hotelRoomTypeId), reservation);

            HotelRoom     room      = ServicesHotelRoom.GetHotelRoomById(r.HotelRoomId);
            HotelRoomType t         = ServicesHotelRoomType.GetHotelRoomTypeById(room.HotelRoomTypeId);
            int           countDays = DbServices.GetIntermediateDates(r.DateOfArrival, r.DateOfArrival).Count;

            string text = ViewReservation.GetTextAboutReservation(r, t, room, countDays);
            await ServicesMessageController.SendMessageAsync(chat, text, Keyboards.ReturnMainMenu);
        }