Exemple #1
0
        public Product Add(Product Product)
        {
            var product = _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.Count(x => x.ID == tagId) == 0)
                    {
                        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(product);
        }
Exemple #2
0
 public DetailOrder Create(DetailOrder order)
 {
     try
     {
         _orderRepository.Add(order);
         _unitOfWork.Commit();
         return(order);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #3
0
 public void Save()
 {
     _unitOfWork.Commit();
 }