コード例 #1
0
        public override BotMessage BuildMsg()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                Follower = db.Follower.Where(f => f.Id == FollowerId).FirstOrDefault();
                Basket   = db.Basket.Where(b => b.FollowerId == Follower.Id && b.Enable).ToList();
            }

            if (Basket != null && Basket.Count() > 0)
            {
                ClearBasketBtn = ClearBasket(Follower.Id);
                ToCheckOutBtn  = ToCheckOut(Follower.Id);
                BasketEditBtn  = BasketEdit(Follower.Id);
                MainMenuBtn    = BuildInlineBtn("На главную", BuildCallData(MainMenuBot.ToMainMenuCmd, MainMenuBot.ModuleName));
                SetInlineKeyBoard();
                string Info = BasketPositionInfo.GetPositionInfo(Follower.Id, BotId);
                base.TextMessage = Bold("Ваша корзина:") + NewLine() + Info;
            }

            else
            {
                base.CallBackTitleText = "Ваша Корзина пуста";
            }


            return(this);
        }
コード例 #2
0
        public ViewBasketMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                follower = db.Follower.Where(f => f.Id == FollowerId).FirstOrDefault();
                Basket   = db.Basket.Where(b => b.FollowerId == follower.Id && b.Enable).ToList();
            }

            if (Basket != null && Basket.Count() > 0)
            {
                ClearBasketBtn = ClearBasket(follower.Id);
                ToAddressList  = ToCheckOut(follower.Id);
                BasketEditBtn  = BasketEdit(follower.Id);
                SetInlineKeyBoard();
                string Info = BasketPositionInfo.GetPositionInfo(follower.Id);
                base.TextMessage = Bold("Ваша корзина:") + NewLine() + Info;
            }

            else
            {
                base.CallBackTitleText = "Ваша Корзина пуста";
            }


            return(this);
        }
コード例 #3
0
        public OrderTempMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                OrderTemp = db.OrderTemp.Where(o => o.FollowerId == FollowerId && o.BotInfoId == BotId).Include(o => o.PaymentType).FirstOrDefault();

                if (OrderTemp != null)
                {
                    var Address = db.Address.Where(a => a.Id == OrderTemp.AddressId).Include(a => a.House).Include(a => a.House.Street).Include(a => a.House.Street.City).FirstOrDefault();

                    string PositionInfo = BasketPositionInfo.GetPositionInfo(FollowerId);

                    string Desc = "-";

                    string PaymentMethod = "-";

                    if (OrderTemp.PaymentType != null && OrderTemp.PaymentType.Name != null)
                    {
                        PaymentMethod = OrderTemp.PaymentType.Name;
                    }

                    if (PositionInfo != null)
                    {
                        if (OrderTemp.Text != null)
                        {
                            Desc = OrderTemp.Text;
                        }

                        base.TextMessage = "Информация о заказе:" +
                                           NewLine() + PositionInfo +
                                           NewLine() + Bold("Адрес доставки: ") + Address.House.Street.City.Name + ", " + Address.House.Street.Name + ", " + Address.House.Number +
                                           NewLine() + Bold("Способ оплаты:") + PaymentMethod +
                                           NewLine() + Bold("Кoмментарий к заказу: ") + Desc;

                        SendBtn             = new InlineKeyboardCallbackButton("Сохранить" + " \ud83d\udcbe", BuildCallData(Bot.OrderBot.CmdOrderSave, OrderBot.ModuleName));
                        DescEditorBtn       = new InlineKeyboardCallbackButton("Комментарий к заказу" + " \ud83d\udccb", BuildCallData(Bot.OrderBot.CmdOrderDesc, OrderBot.ModuleName));
                        AddressEditor       = new InlineKeyboardCallbackButton("Изменить адрес" + " \ud83d\udd8a", BuildCallData(Bot.OrderBot.CmdAddressEditor, OrderBot.ModuleName));
                        PaymentMethodEditor = new InlineKeyboardCallbackButton("Изменить способ оплаты" + " \ud83d\udd8a", BuildCallData("PaymentMethodEditor", OrderBot.ModuleName));

                        SetInlineKeyBoard();
                        return(this);
                    }

                    else
                    {
                        return(null);
                    }
                }

                else
                {
                    return(null);
                }
            }
        }
コード例 #4
0
        public override BotMessage BuildMsg()
        {
            string Desc = "-";

            string PaymentMethod = "-";

            SendBtn                 = new InlineKeyboardCallbackButton("Сохранить" + " \ud83d\udcbe", BuildCallData(Bot.OrderBot.CmdOrderSave, OrderBot.ModuleName));
            DescEditorBtn           = new InlineKeyboardCallbackButton("Комментарий к заказу" + " \ud83d\udccb", BuildCallData(Bot.OrderBot.CmdOrderDesc, OrderBot.ModuleName));
            MethodOfObtainingEditor = new InlineKeyboardCallbackButton("Изменить способ получения заказа" + " \ud83d\udd8a", BuildCallData(Bot.OrderBot.MethodOfObtainingListCmd, OrderBot.ModuleName));
            PaymentMethodEditor     = new InlineKeyboardCallbackButton("Изменить способ оплаты" + " \ud83d\udd8a", BuildCallData(Bot.OrderBot.GetPaymentMethodListCmd, OrderBot.ModuleName));

            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                OrderTemp = db.OrderTemp.Where(o => o.FollowerId == FollowerId && o.BotInfoId == BotId).Include(o => o.PaymentType).LastOrDefault();
                string PositionInfo = BasketPositionInfo.GetPositionInfo(FollowerId, BotId);
                Configuration = db.Configuration.Where(c => c.BotInfoId == BotId).FirstOrDefault();
                double BasketTotalPrice = BusinessLayer.BasketFunction.BasketTotalPrice(FollowerId, BotId);

                if (OrderTemp != null)
                {
                    double ShipPice = 0;

                    if (OrderTemp.AddressId != null) // если  способ получения заказа "Доставка" то определям адрес доставки и стоимость доставки
                    {
                        Address = db.Address.Where(a => a.Id == OrderTemp.AddressId).Include(a => a.House).Include(a => a.House.Street).Include(a => a.House.Street.City).FirstOrDefault();

                        //определям стоимост доставки
                        //Стоимость заказа подходит под условия бесплатной доставки
                        if (Configuration.ShipPrice > 0 && BasketTotalPrice >= Configuration.FreeShipPrice)
                        {
                            ShipPice = 0;
                        }

                        //Стоимость заказа НЕ подходит под условия бесплатной доставки
                        if (Configuration.ShipPrice > 0 && BasketTotalPrice < Configuration.FreeShipPrice)
                        {
                            ShipPice = Configuration.ShipPrice;
                        }

                        //Доставка бесплатая
                        if (Configuration.ShipPrice == 0)
                        {
                            ShipPice = 0;
                        }
                    }

                    if (OrderTemp.PickupPointId != null)
                    {
                        PickupPoint = db.PickupPoint.Find(OrderTemp.PickupPointId);
                    }


                    if (OrderTemp.PaymentType != null && OrderTemp.PaymentType.Name != null)
                    {
                        PaymentMethod = OrderTemp.PaymentType.Name;
                    }

                    if (PositionInfo != null)
                    {
                        if (OrderTemp.Text != null)
                        {
                            Desc = OrderTemp.Text;
                        }

                        if (OrderTemp.AddressId != null)
                        {
                            base.TextMessage = "Информация о заказе:" +
                                               NewLine() + PositionInfo +
                                               NewLine() + Bold("Адрес доставки: ") + Address.House.Street.City.Name + ", " + Address.House.Street.Name + ", д. " + Address.House.Number + "," + Address.House.Apartment +
                                               NewLine() + Bold("Стоимость доставки:") + ShipPice.ToString() +
                                               NewLine() + Bold("Способ оплаты:") + PaymentMethod +
                                               NewLine() + Bold("Кoмментарий к заказу: ") + Desc;
                        }

                        if (OrderTemp.PickupPointId != null)
                        {
                            base.TextMessage = "Информация о заказе:" +
                                               NewLine() + PositionInfo +
                                               NewLine() + Bold("Пункт самовывоза: ") + PickupPoint.Name +
                                               NewLine() + Bold("Способ оплаты:") + PaymentMethod +
                                               NewLine() + Bold("Кoмментарий к заказу: ") + Desc;
                        }

                        SetInlineKeyBoard();
                        return(this);
                    }

                    else
                    {
                        return(null);
                    }
                }

                else
                {
                    return(null);
                }
            }
        }