Exemplo n.º 1
0
        /// <summary>
        /// The add.
        /// </summary>
        /// <param name="product">
        /// The product.
        /// </param>
        /// <param name="productAttributeValueSets">
        /// The product attribute value sets.
        /// </param>
        /// <param name="pictureIDs">
        /// The picture i ds.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int Add(Product product, List<Product_AttributeValueSet> productAttributeValueSets, List<string> pictureIDs, string masterPictureID)
        {
            var productID = 0;
            try
            {
                productID = this.productDA.Insert(product);
                //if (productAttributeValueSets != null && productAttributeValueSets.Count > 0)
                //{
                //    foreach (var productAttributeValueSet in productAttributeValueSets)
                //    {
                //        productAttributeValueSet.ProductID = productID;
                //        this.productAttributeValueSetDA.Insert(productAttributeValueSet, transaction);
                //    }
                //}

                foreach (var pictureID in pictureIDs)
                {
                    var productPicture = new Product_Picture
                                             {
                                                 ProductID = productID,
                                                 PictureID = Convert.ToInt32(pictureID),
                                                 IsMaster = pictureID == masterPictureID ? true : false
                                             };

                    this.productPictureDA.Insert(productPicture);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            return productID;
        }
Exemplo n.º 2
0
        /// <summary>
        /// The insert.
        /// </summary>
        /// <param name="productPicture">
        /// The product picture.
        /// </param>
        /// <param name="transaction">
        /// The transaction.
        /// </param>
        public void Insert(Product_Picture productPicture)
        {
            if (productPicture == null)
            {
                throw new ArgumentNullException("productPicture");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ProductID",
                                         SqlDbType.Int,
                                         productPicture.ProductID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "PictureID",
                                         SqlDbType.Int,
                                         productPicture.PictureID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsMaster",
                                         SqlDbType.Bit,
                                         productPicture.IsMaster,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Product_Picture_Insert", parameters, null);
        }