private string UnitsList()
        {
            var list = UnitsFunction.UnitsList();

            string res = String.Empty;

            foreach (var u in list)
            {
                res += u.Name + ",";
            }

            return(res);
        }
        private async Task <IActionResult> UpdUnit()
        {
            string product_name = OriginalMessage.Substring(EnterUnitForceReply.Length);

            string unit_name = ReplyToMessageText.Trim();

            var UnitList = UnitsList();

            ProductFunction = new ProductFunction();

            var product = ProductFunction.GetProduct(product_name);

            var Unit = UnitsFunction.GetUnits(unit_name);

            ProductFunction = new ProductFunction();

            if (Unit != null && product != null)
            {
                product = ProductFunction.UpdateUnit(product.Id, Unit.Id);
                ProductFunction.Dispose();
            }

            if (Unit == null && product != null) // пользваотель указа ед. измерения но ее не удалось найти. Выбираем первую из существующих
            {
                var list = UnitsFunction.UnitsList();
                await SendMessage(new BotMessage { TextMessage = "Не удалось найти еденицу измерения. Выбрано:" + list.FirstOrDefault().Name });

                product = ProductFunction.UpdateUnit(product.Id, list.FirstOrDefault().Id);
                ProductFunction.Dispose();
            }

            if (product != null && product.UnitId > 0)
            {
                return(await SendTextMessageAndForceReply(product.Name + " /adminproduct" + product.Id, EnterPriceForceReply + product.Name));
            }


            else
            {
                return(await SendTextMessageAndForceReply(product.Name + " /adminproduct" + product.Id +
                                                          " Еденицы измерения:" + UnitList, EnterUnitForceReply + product.Name));
            }
        }
Exemplo n.º 3
0
        public IActionResult Editor(int id)
        {
            ProductFunc = new ProductFunction();

            if (id > 0)
            {
                var product = ProductFunc.GetProduct(id);

                if (product.MainPhotoNavigation != null) // вытаскиваем главную фотографию и готовим ее к отображению на странице
                {
                    string imageBase64Data = Convert.ToBase64String(product.MainPhotoNavigation.Fs);
                    string imageDataURL    = string.Format("data:image/png;base64,{0}", imageBase64Data);
                    ViewBag.ImageData = imageDataURL;
                }

                ViewBag.Category = new SelectList(CategoryFunction.GetListCategory(), "Id", "Name", product.CategoryId);

                ViewBag.Currency = CurrencyFunction.CurrencyList();

                ViewBag.Unit = new SelectList(UnitsFunction.UnitsList(), "Id", "Name", product.UnitId);

                ProductFunc.Dispose();

                if (product != null)
                {
                    return(View(product));
                }

                else
                {
                    return(NoContent());
                }
            }



            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public override BotMessage BuildMsg()
        {
            UnitList = UnitsFunction.UnitsList();

            UnitBtn = new Telegram.Bot.Types.KeyboardButton[UnitList.Count][];

            int count = 0;

            base.TextMessage = "1";

            foreach (var unit in UnitList)
            {
                UnitBtn[count]    = new Telegram.Bot.Types.KeyboardButton[1];
                UnitBtn[count][0] = new Telegram.Bot.Types.KeyboardButton("Еденица измерения:" + unit.Name);
                count++;
            }

            Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup replyKeyboard = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup(UnitBtn);

            base.MessageReplyMarkup = replyKeyboard;

            return(this);
        }
Exemplo n.º 5
0
        public IActionResult Creator()
        {
            var conf = Bot.GeneralFunction.GetBotInfo();

            var catlist = CategoryFunction.GetListCategory();

            Product product = new Product();

            product.Id           = 0;
            product.Name         = String.Empty;
            product.CategoryId   = 0;
            product.UnitId       = 1;
            product.TelegraphUrl = String.Empty;
            product.Text         = String.Empty;
            product.PhotoUrl     = String.Empty;
            product.CurrentPrice = new ProductPrice {
                CurrencyId = conf.Configuration.CurrencyId, Value = 0
            };
            product.Stock.Add(new Stock {
                Balance = 100, ProductId = 0
            });

            if (catlist.Count > 0)
            {
                ViewBag.Category = new SelectList(catlist, "Id", "Name", catlist.FirstOrDefault().Id);
            }

            else
            {
                ViewBag.Category = new SelectList(catlist, "Id", "Name", 0);
            }


            ViewBag.Currency = CurrencyFunction.CurrencyList();
            ViewBag.Unit     = new SelectList(UnitsFunction.UnitsList(), "Id", "Name", product.UnitId);
            return(View("Editor", product));
        }