Example #1
0
        public void AddProductKeyword(int productId, string keyword)
        {
            ProductEntity     p        = new ProductEntity(productId);
            KeywordCollection keywords = new KeywordCollection();

            keywords.GetMulti(null);

            if (keywords.Any(pr => pr.Keyword == keyword))
            {
                int keywordId = keywords.Where <KeywordEntity>(f => f.Keyword == keyword).FirstOrDefault().Id;

                ProductKeywordEntity productKeyword = new ProductKeywordEntity();
                productKeyword.KeywordId = keywordId;
                productKeyword.ProductId = productId;
                productKeyword.Save();
            }
            else
            {
                KeywordEntity k = new KeywordEntity();
                k.Keyword = keyword;
                k.Save();

                ProductKeywordEntity newProductKeyword = new ProductKeywordEntity();
                newProductKeyword.KeywordId = k.Id;
                newProductKeyword.ProductId = productId;
                newProductKeyword.Save();
            }
        }
        /// <summary>Creates a new, empty ProductKeywordEntity object.</summary>
        /// <returns>A new, empty ProductKeywordEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new ProductKeywordEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductKeyword
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
Example #3
0
        public bool DeleteProductKeyword(int productId, int keywordId)
        {
            ProductKeywordEntity pk = new ProductKeywordEntity(keywordId, productId);

            return(pk.Delete());
        }