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)); } }
/// <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()); } }