public void Update(Product product) { _productRepository.Update(product); _unitOfWork.Commit(); if (!string.IsNullOrEmpty(product.Tags)) { string[] listTags = product.Tags.Split(','); foreach (var item in listTags) { var tagId = StringHelper.ToUnsignString(item); if (_tagReponsitory.Count(x => x.ID == tagId) == 0) { Tag tag = new Tag() { ID = tagId, Name = item, Type = CommonConstant.ProductTag, }; _tagReponsitory.Add(tag); } int coutProductTag = _productTagRepository.GetMulti(x => (x.ProductID == product.ID && x.TagID == tagId)).Count(); if (coutProductTag == 0) { ProductTag productTag = new ProductTag() { ProductID = product.ID, TagID = tagId, }; _productTagRepository.Add(productTag); } } } }
public IEnumerable <ProductTag> GetAll(string keyword) { if (string.IsNullOrEmpty(keyword)) { return(_productTagRepository.GetAll()); } else { return(_productTagRepository.GetMulti(x => x.ProductID.ToString() .Contains(keyword) || x.TagID.Contains(keyword))); } }
public IEnumerable <Tag> GetListTagByProductId(int id) { return(_productTagRepository.GetMulti(x => x.ProductID == id, new string[] { "Tag" }).Select(y => y.Tag)); }
public IEnumerable <Tag> GetListTagByProductId(int productId) { var tags = _productTagRepository.GetMulti(x => x.ProductID == productId, new string[] { "Tag" }).Select(y => y.Tag); return(tags); }