Beispiel #1
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as MessageEventArgs).Message.Text;
            Chat   chat      = (e as MessageEventArgs).Message.Chat;

            responder.userTempData.TryGetValue("DateOfArrival", out string dateOfArrival);

            if (!Validator.CheckDateFormat(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadDateFormat);

                return;
            }
            else if (!Validator.CheckDateBigerCurrent(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadDateLessCurrent);

                return;
            }
            else if (!Validator.CheckDateRange(dateOfArrival, userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadDateRange);

                return;
            }
            responder.userTempData["DateOfDeparture"] = userInput;
            responder.SetState(new BookRoom_02());
        }
        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());
        }
        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());
        }
Beispiel #4
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            MessageEventArgs ev   = e as MessageEventArgs;
            Chat             chat = ev.Message.Chat;
            string           userInput;

            if (ev.Message.Type == MessageType.Text)
            {
                userInput = ev.Message.Text;
            }
            else if (ev.Message.Type == MessageType.Contact)
            {
                userInput = ev.Message.Contact.PhoneNumber;
            }
            else
            {
                return;
            }

            if (!Validator.CheckPhoneNumber(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadPhoneNumber);

                return;
            }
            responder.userTempData["Number"] = userInput;
            responder.SetState(new BookRoom_09());
        }
 public override async void OnStateChange(Chat chat)
 {
     DateTime      firstDate  = DateTime.Now.AddDays(1);
     DateTime      secondDate = firstDate.AddDays(6);
     List <string> dates      = DbServices.GetIntermediateDates(firstDate, secondDate);
     await ServicesMessageController.SendMessageAsync(
         chat, "Введіть дату прибуття", Keyboards.NextDates(dates));
 }
Beispiel #6
0
 public override async void OnStateChange(Chat chat)
 {
     responder.userTempData.TryGetValue("DateOfArrival", out string firstDateString);
     DateTime      firstDate  = DateTime.Parse(firstDateString).AddDays(1);
     DateTime      secondDate = firstDate.AddDays(6);
     List <string> dates      = DbServices.GetIntermediateDates(firstDate, secondDate);
     await ServicesMessageController.SendMessageAsync(
         chat, "Введіть дату відбуття", Keyboards.NextDates(dates));
 }
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as MessageEventArgs).Message.Text;
            Chat   chat      = (e as MessageEventArgs).Message.Chat;

            if (!Validator.CheckName(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadName);

                return;
            }
            responder.userTempData["MiddleName"] = userInput;
            responder.SetState(new BookRoom_08());
        }
        public override async void OnStateChange(Chat chat)
        {
            List <HotelRoomType> listRoomTypes = ServicesHotelRoomType.GetHotelRoomTypes();

            if (listRoomTypes.Count == 0)
            {
                await ServicesMessageController.SendMessageAsync(chat, "Номерів немає", Keyboards.ReturnMainMenu);

                return;
            }

            IReplyMarkup markup = Keyboards.GetRoomTypesMenu(listRoomTypes);
            await ServicesMessageController.SendMessageAsync(chat, "Оберіть тип номеру", markup);
        }
Beispiel #9
0
        public override async void OnStateChange(Chat chat)
        {
            var listReservation = DbServices.GetValidReservation(chat.Id, DateTime.Now);

            if (listReservation.Count == 0)
            {
                await ServicesMessageController.SendMessageAsync(chat, "Бронювань немає", Keyboards.ReturnMainMenu);

                responder.SetState(new MainMenu());
                return;
            }
            IReplyMarkup markup = Keyboards.GetReservationsMenu(listReservation);

            await ServicesMessageController.SendMessageAsync(chat, "Бронювання: ", markup);
        }
        public override async void OnStateChange(Chat chat)
        {
            responder.userTempData.TryGetValue("DateOfArrival", out arrival);
            responder.userTempData.TryGetValue("DateOfDeparture", out departure);
            responder.userTempData.TryGetValue("NumberOfAdults", out adults);
            responder.userTempData.TryGetValue("NumberOfChildren", out children);

            var listRoomTypes = DbServices.GetAviableRoomTypes(arrival, departure, int.Parse(adults), int.Parse(children));

            if (listRoomTypes.Count <= 0)
            {
                await ServicesMessageController.SendMessageAsync(
                    chat, "На вказаний період немає доступних номерів.", Keyboards.ReturnMainMenu);
            }

            IReplyMarkup markup = Keyboards.GetRoomTypesMenu(listRoomTypes, "Замовити: ");
            await ServicesMessageController.SendMessageAsync(chat, "Оберіть тип номеру", markup);
        }
Beispiel #11
0
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as MessageEventArgs).Message.Text;
            Chat   chat      = (e as MessageEventArgs).Message.Chat;

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

                return;
            }
            else if (!Validator.CheckNumberRange(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadNumberRange);

                return;
            }
            responder.userTempData["NumberOfChildren"] = userInput;
            responder.SetState(new BookRoom_04());
        }
Beispiel #12
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());
        }
Beispiel #13
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);
        }
 public override async void OnStateChange(Chat chat)
 {
     await ServicesMessageController.SendMessageAsync(chat, "Введіть по батькові");
 }
Beispiel #15
0
 public override async void OnStateChange(Chat chat)
 {
     await ServicesMessageController.SendMessageAsync(
         chat, "Введіть ім’я",
         Keyboards.Text(chat.FirstName));
 }
Beispiel #16
0
 public override async void OnStateChange(Chat chat)
 {
     await ServicesMessageController.SendMessageAsync(chat, "Введіть кількість дорослих", Keyboards.Adults);
 }
Beispiel #17
0
 public override async void OnStateChange(Chat chat)
 {
     responder.userTempData.Clear();
     await ServicesMessageController.SendMessageAsync(chat.Id, "Головне меню", Keyboards.MainKeyboard);
 }
Beispiel #18
0
 public override async void OnStateChange(Chat chat)
 {
     IReplyMarkup markup = View.Keyboards.GetRequestcontactKeyboard("📞 Мій номер");
     await ServicesMessageController.SendMessageAsync(chat, "Введіть номер телефону", markup);
 }
Beispiel #19
0
 public override async void OnStateChange(Chat chat)
 {
     await ServicesMessageController.SendMessageAsync(chat, "Введіть кількість дітей", Keyboards.Children);
 }