Exemplo n.º 1
0
        public void CustomerDisconnected()
        {
            //TODO: Get first and if connect, then remove from queue
            var customerChatId = WaitingQueueRepo.Dequeue();

            if (customerChatId == default(long))
            {
                return;
            }

            var customer = SubscriberRepo.GetByChatId(customerChatId);

            ConnectionManager.TryConnect(customer);

            var waitersChatIds = WaitingQueueRepo.GetAll().ToList();

            foreach (var waiterChatId in waitersChatIds)
            {
                TelegramClient.SendTextMessageAsync(waiterChatId, $"You're Number {waitersChatIds.IndexOf(waiterChatId) + 1} In Queue.",
                                                    replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer));
            }
        }
Exemplo n.º 2
0
        public void Cancel(SubscriberRecord customer)
        {
            if (!WaitingQueueRepo.HasWaiter(customer))
            {
                TelegramClient.SendTextMessageAsync(customer.ChatId, "You're not In Queue.",
                                                    replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer));
                return;
            }

            var removedPosition = WaitingQueueRepo.GetPosition(customer);

            WaitingQueueRepo.Remove(customer);
            TelegramClient.SendTextMessageAsync(customer.ChatId, "You're not In Queue Anymore.",
                                                replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer));

            var waiters = WaitingQueueRepo.GetAll().ToList();
            var waitersToNotifyChatIds = waiters.Skip(removedPosition - 1);

            foreach (var chatId in waitersToNotifyChatIds)
            {
                TelegramClient.SendTextMessageAsync(chatId, $"You're Number {waiters.IndexOf(chatId) + 1} In Queue.",
                                                    replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer));
            }
        }