/// <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)); } }
/// <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)); } } }