Exemple #1
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);
            }
        }
Exemple #2
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));
        }