Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="splited"></param>
        /// <param name="e"></param>
        private static void ServiceAddOrUpdate(string[] splited, MessageEventArgs e)
        {
            var servicess = new DataContext().Services.FirstOrDefault(f => EF.Functions.Like(f.Name.ToLower(), $"%{splited[1].ToLower()}%"));

            if (servicess != null)
            {
                servicess.Price = Convert.ToInt32(splited[2]);
                ServicesssDoService.AddOrUpdate(servicess);
                return;
            }
            var service = new Servicess();

            service.Name  = splited[1];
            service.Price = Convert.ToInt32(splited[2]);
            ServicesssDoService.AddOrUpdate(service);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chatId"></param>
        /// <param name="messageId"></param>
        /// <returns></returns>
        private static async Task TryInliniButtonForServices(long chatId, int messageId)
        {
            var lang     = await new DataContext().Languages.FirstOrDefaultAsync(f => f.ChatId == chatId);
            var langId   = lang != null ? lang.LanguageId : 1;
            var services = await ServicesssDoService.GetAll();

            services = services.OrderBy(f => f.Id).ToList();
            var inlines = new List <InlineKeyboardButton[]>();

            for (int i = 0; i < services.Count; i++)
            {
                if (i + 1 >= services.Count)
                {
                    inlines.Add(new[] { InlineKeyboardButton.WithCallbackData($"{ services[i].Name } - {services[i].Price}", services[i].Id.ToString()) });
                }
                else
                {
                    inlines.Add(new[] { InlineKeyboardButton.WithCallbackData($"{ services[i].Name } - {services[i].Price}", services[i].Id.ToString()), InlineKeyboardButton.WithCallbackData($"{ services[i + 1].Name } - {services[i + 1].Price}", services[i + 1].Id.ToString()) });
                }
                i++;
            }

            inlines.Add(new[] { InlineKeyboardButton.WithCallbackData(langId == 1 ? "🧾 Buyurtma berish" : "🧾 Заказать", "order") });
            inlines.Add(new[] { InlineKeyboardButton.WithCallbackData("Tilni o'zgartirish/Изменить язык", "setLang") });
            var inlineKeyboard = new InlineKeyboardMarkup(inlines);


            if (messageId == 0)
            {
                await Bot.SendTextMessageAsync(chatId, langId == 1? "Iltimos xizmat turini tanlang" : "Пожалуйста, выберите тип услуги", replyMarkup : inlineKeyboard);
            }
            else
            {
                await Bot.EditMessageTextAsync(chatId, messageId, langId == 1? "Iltimos xizmat turini tanlang" : "Пожалуйста, выберите тип услуги", replyMarkup : inlineKeyboard);
            }
        }