예제 #1
0
        /// <summary>
        /// Save product to DB.
        /// </summary>
        /// <param name="productDto">Product DTO to save to DB.</param>
        public void AddProduct(ProductDataContract product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            using (var service = ProductsServiceFactory.CreateWithDbRepository())
            {
                service.SaveProduct(ToDto(product));
            }
        }
예제 #2
0
        /// <summary>
        /// Save several products to DB.
        /// </summary>
        /// <param name="productDtos">List of product DTOs to save to DB.</param>
        public void AddSeveralProducts(IEnumerable <ProductDataContract> products)
        {
            if (products == null)
            {
                throw new ArgumentNullException(nameof(products));
            }

            using (var service = ProductsServiceFactory.CreateWithDbRepository())
            {
                foreach (var product in products)
                {
                    service.SaveProduct(ToDto(product));
                }
            }
        }