コード例 #1
0
        public override BotMessage BuildMsg()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
                AddressIdList = db.Address.Where(a => a.FollowerId == FollowerId).Include(a => a.House).Include(a => a.House.Street).Include(a => a.House.Street.House).Include(a => a.House.Street.City).ToList();


            if (AddressIdList != null && AddressIdList.Count() > 0)
            {
                AddressListBtn = new InlineKeyboardCallbackButton[AddressIdList.Count() + 2][];
                int counter = 0;

                foreach (Address address in AddressIdList)
                {
                    int?HouseId = address.HouseId;
                    var House   = address.House;
                    var Street  = address.House.Street;
                    var City    = address.House.Street.City;

                    string Adr = City.Name + ", " + Street.Name + ", д. " + House.Number + ", " + House.Apartment;
                    AddressListBtn[counter]    = new InlineKeyboardCallbackButton[1];
                    AddressListBtn[counter][0] = base.BuildInlineBtn(Adr, BuildCallData(Bot.OrderBot.CmdSelectAddress, Bot.OrderBot.ModuleName, address.Id), base.HouseEmodji);
                    counter++;
                }

                AddressListBtn[counter]    = new InlineKeyboardCallbackButton[1];
                AddressListBtn[counter][0] = AddAddress();

                AddressListBtn[counter + 1]    = new InlineKeyboardCallbackButton[1];
                AddressListBtn[counter + 1][0] = BackBtn;


                base.MessageReplyMarkup = new InlineKeyboardMarkup(AddressListBtn);
                base.TextMessage        = "Выберите адрес";
            }

            else
            {
                AddressListBtn          = new InlineKeyboardCallbackButton[1][];
                AddressListBtn[0]       = new InlineKeyboardCallbackButton[1];
                AddressListBtn[0][0]    = AddAddress();
                base.MessageReplyMarkup = new InlineKeyboardMarkup(AddressListBtn);
                base.TextMessage        = "Выберите адрес";
            }

            return(this);
        }
コード例 #2
0
        public AddressListMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
                AddressIdList = db.Address.Where(a => a.FollowerId == FollowerId).Include(a => a.House).Include(a => a.House.Street).Include(a => a.House.Street.House).Include(a => a.House.Street.City).ToList();


            if (AddressIdList != null && AddressIdList.Count() > 0)
            {
                AddressListBtn = new InlineKeyboardCallbackButton[AddressIdList.Count() + 2][];
                int counter = 0;

                foreach (Address address in AddressIdList)
                {
                    int?HouseId = address.HouseId;
                    var House   = address.House;
                    var Street  = address.House.Street;
                    var City    = address.House.Street.City;

                    string Adr = City.Name + ", " + Street.Name + ", " + House.Number;
                    AddressListBtn[counter]    = new InlineKeyboardCallbackButton[1];
                    AddressListBtn[counter][0] = AddressBtn(Adr, Convert.ToInt32(address.Id));
                    counter++;
                }

                AddressListBtn[counter]    = new InlineKeyboardCallbackButton[1];
                AddressListBtn[counter][0] = AddAddress();

                AddressListBtn[counter + 1]    = new InlineKeyboardCallbackButton[1];
                AddressListBtn[counter + 1][0] = BackBtn;


                base.MessageReplyMarkup = new InlineKeyboardMarkup(AddressListBtn);
                base.TextMessage        = "Выберите адрес";
            }

            else
            {
                AddressListBtn          = new InlineKeyboardCallbackButton[1][];
                AddressListBtn[0]       = new InlineKeyboardCallbackButton[1];
                AddressListBtn[0][0]    = AddAddress();
                base.MessageReplyMarkup = new InlineKeyboardMarkup(AddressListBtn);
                base.TextMessage        = "Выберите адрес";
            }

            return(this);
        }