private string CategoryList() { var list = CategoryFunction.GetListCategory(); string res = String.Empty; foreach (Category cat in list) { res += cat.Name + ","; } return(res); }
/// <summary> /// Показать все категории /// </summary> /// <returns></returns> private async Task <IActionResult> SendCategoryList() { var list = CategoryFunction.GetListCategory(); string categoryListText = String.Empty; foreach (Category cat in list) { categoryListText += cat.Name + ", "; } await SendMessage(new BotMessage { TextMessage = "Категории:" + categoryListText }); await SendForceReplyMessage(ProductEditCategoryReply); return(OkResult); }
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); } }
private async Task <IActionResult> UpdCategory() { string product_name = OriginalMessage.Substring(EnterCategoryForceReply.Length); string category_name = ReplyToMessageText; var category = CategoryFunction.GetCategory(category_name); var category_list = CategoryList(); ProductFunction = new ProductFunction(); Product = ProductFunction.GetProduct(product_name); if (category == null) { category = CategoryFunction.InsertCategory(category_name); } if (category != null && Product != null) { Product = ProductFunction.GetProduct(product_name); ProductFunction.UpdateCategory(Product.Id, category.Id); ProductFunction.Dispose(); return(await SendTextMessageAndForceReply("Введите краткое описание вашего товара. Максмимум 100 символов", EnterTextForceReply + Product.Name)); } else { ProductFunction.Dispose(); return(await SendTextMessageAndForceReply("Введите название новой категории или выберите уже существующую." + "Список категорий:" + category_list, EnterCategoryForceReply + product_name)); } }
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)); }
/// <summary> /// Обновить категорию /// </summary> /// <returns></returns> private async Task <IActionResult> UpdateProductCategory() { ProductFunction = new ProductFunction(); int ProductId = ProductGet(ProductEditCategoryReply); string CatName = base.ReplyToMessageText; var category = CategoryFunction.GetCategory(CatName); if (category != null) { var product = ProductFunction.UpdateCategory(ProductId, category.Id); ProductFunction.Dispose(); return(await SendProductFunc(product)); } else { ProductFunction.Dispose(); await SendMessage(new BotMessage { TextMessage = "Категория не найдена!" }); return(await SendCategoryList()); } }