Пример #1
0
        string Shop(string shop, out string reply_markup)
        {
            string answer = "Магазин продуктов";

            reply_markup = "";
            Category categories;

            char[]   spl      = { ' ' };
            string[] shops    = shop.Split(spl, StringSplitOptions.RemoveEmptyEntries);
            string   ncat     = shops[0];
            string   nproduct = "q";

            if (shops.Length > 1)
            {
                nproduct = shops[1];
            }
            Product pr = new Product();
            List <InlineKeyboardButton> kb = new List <InlineKeyboardButton>();

            using (UpdateDbContext db = new UpdateDbContext())
            {
                if (shops.Length == 1)
                {
                    var product = db.Products.ToList();
                    categories = db.Categorys.Where(x => x.NameCategory == ncat).First();
                }
                else
                {
                    var product = db.Products.ToList();
                    //categories = db.Categorys.Where(x => x.NameCategory == ncat).First();
                    categories = db.Categorys.Where(x => x.NameCategory == ncat).First();
                    pr         = categories.Products.Where(x => x.NameProduct == nproduct).First();
                }
            }
            InlineKeyboard keyboard = new InlineKeyboard();
            int            i        = 0;

            if (shops.Length == 1)
            {
                foreach (var item in categories.Products)
                {
                    keyboard.AddButton(new InlineKeyboardButton(item.NameProduct, item.Category.NameCategory + " " + item.NameProduct), i++ / 2);
                }
            }
            if (shops.Length > 1)
            {
                foreach (var item in categories.Products)
                {
                    keyboard.AddButton(new InlineKeyboardButton(item.NameProduct, item.Category.NameCategory + " " + item.NameProduct), i++ / 2);
                }
                answer = pr.NameProduct + "    " + pr.Price + "   " + pr.Description;
            }
            AddMainButton(keyboard);
            reply_markup = JsonConvert.SerializeObject(keyboard);


            return(answer);
        }
Пример #2
0
        void AddMainButton(InlineKeyboard keyboard)
        {
            List <InlineKeyboardButton> line = new List <InlineKeyboardButton>()
            {
                new InlineKeyboardButton("Есть вопрос", "?"),
                new InlineKeyboardButton("О нас", "about")
            };

            keyboard.AddLine(line);
        }
Пример #3
0
        void InlineMenu(long chat_id)
        {
            InlineKeyboardButton        button1    = new InlineKeyboardButton("ya", "ya.ru");
            InlineKeyboardButton        button2    = new InlineKeyboardButton("vk", "vk.ru");
            List <InlineKeyboardButton> listInline = new List <InlineKeyboardButton> {
                button1, button2
            };
            List <List <InlineKeyboardButton> > listttInline = new List <List <InlineKeyboardButton> >()
            {
                listInline
            };
            InlineKeyboard kb           = new InlineKeyboard(listttInline);
            string         reply_markup = JsonConvert.SerializeObject(kb);

            SendMessage(chat_id, "Inline_menu", reply_markup);
        }
Пример #4
0
        private string MainMenu(out string reply_markup)
        {
            List <Category>             categories;
            List <InlineKeyboardButton> kb = new List <InlineKeyboardButton>();

            using (UpdateDbContext db = new UpdateDbContext())
            {
                categories = db.Categorys.ToList();
            }
            InlineKeyboard keyboard = new InlineKeyboard();
            int            i        = 0;

            foreach (var item in categories)
            {
                keyboard.AddButton(new InlineKeyboardButton(item.NameCategory, item.NameCategory), i++ / 2);
            }
            AddMainButton(keyboard);
            reply_markup = JsonConvert.SerializeObject(keyboard);
            return("Все категории магазина");
        }