コード例 #1
0
        private async Task <IActionResult> AddProduct()
        {
            string product_name = ReplyToMessageText.Trim();

            ProductFunction = new ProductFunction();

            var product = ProductFunction.GetProduct(product_name);

            var categorys = CategoryList();

            bool IsProhibited = ProductFunction.NameIsProhibited(product_name);

            if (product != null)
            {
                return(await SendTextMessageAndForceReply("Товар с таким именем уже существует", EnterProductNameForceReply));
            }

            if (IsProhibited)
            {
                return(await SendTextMessageAndForceReply("Запрещенное название!", EnterProductNameForceReply));
            }

            else
            {
                product = ProductFunction.InsertProduct(product_name, true);

                if (product != null && !IsProhibited)
                {
                    return(await SendTextMessageAndForceReply("Введите название новой категории или выберите уже существующую." + BotMessage.NewLine()
                                                              + BotMessage.Bold("Список категорий:") + categorys, EnterCategoryForceReply + product.Name));
                }

                else
                {
                    return(await SendTextMessageAndForceReply("Неизвестная ошибка", EnterProductNameForceReply));
                }
            }
        }