Example #1
0
        /// <summary>
        /// 添加商品关键词
        /// </summary>
        public ActionResult AddProductKeyword(string keyword, int relevancy = 0, int pid = -1)
        {
            PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(pid);

            if (partProductInfo == null)
            {
                return(PromptView(Url.Action("productkeywordlist", new { pid = pid }), "商品不存在"));
            }

            if (string.IsNullOrWhiteSpace(keyword))
            {
                return(PromptView(Url.Action("productkeywordlist", new { pid = pid }), "关键词不能为空"));
            }

            if (keyword.Length > 20)
            {
                return(PromptView(Url.Action("productkeywordlist", new { pid = pid }), "关键词最多只能输入20个字"));
            }

            if (Searches.IsExistProductKeyword(pid, keyword))
            {
                return(PromptView(Url.Action("productkeywordlist", new { pid = pid }), "关键词已经存在"));
            }

            ProductKeywordInfo productKeywordInfo = new ProductKeywordInfo
            {
                Keyword   = keyword,
                Pid       = pid,
                Relevancy = relevancy
            };

            Searches.CreateProductKeyword(productKeywordInfo);
            AddMallAdminLog("添加商品关键词", "添加商品关键词,商品ID为:" + pid);
            return(PromptView(Url.Action("productkeywordlist", new { pid = pid }), "商品关键词添加成功"));
        }