Ejemplo n.º 1
0
        public Product Add(Product product)
        {
            var product1 = _productRepository.Add(product);

            _unitOfWork.Commit();
            if (!string.IsNullOrEmpty(product.Tags))
            {
                string[] tags = product.Tags.Split(',');
                for (var i = 0; i < tags.Length; i++)
                {
                    var TagId = StringHelper.ToUnsignString(tags[i]);
                    if (_tagRepository.CheckContains(x => x.ID == TagId) == false)
                    {
                        Tag tag = new Tag();
                        tag.ID   = TagId;
                        tag.Name = tags[i];
                        tag.Type = CommonConstants.ProductTag;
                        _tagRepository.Add(tag);
                    }
                    ProductTag productTag = new ProductTag();
                    productTag.ProductID = product.ID;
                    productTag.TagID     = TagId;
                    _productTagRepository.Add(productTag);
                }
            }
            return(product1);
        }
Ejemplo n.º 2
0
 public bool CheckTitleContain(string title)
 {
     return(_tagRep.CheckContains(n => n.TagTitle.Equals(title)));
 }