private SubscriberRecord FairSelectSupporter() { var supporters = SupporterRepo.GetAll(); var connections = ConnectionRepo.GetAll(); //TODO: Fair select return(supporters.FirstOrDefault(x => connections.All(c => c.SupporterChatId != x.ChatId))); }
public bool TryConnect(SubscriberRecord customer) { var supporters = SupporterRepo.GetAll(); var connections = ConnectionRepo.GetAll(); if (supporters.Count() > connections.Count()) { var supporter = FairSelectSupporter(); ConnectionRepo.Add(supporter, customer); TelegramClient.SendTextMessageAsync(supporter.ChatId, $"You're Connected to {customer.FirstName} {customer.LastName}", replyMarkup: StateManager.GetSupporterReplyKeyboardMarkup(supporter)); TelegramClient.SendTextMessageAsync(customer.ChatId, "You're Connected.", replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer)); return(true); } return(false); }