private ProductDto ToDto(ProductDataContract dataContract) { return(new ProductDto { Name = dataContract.Name, Price = dataContract.Price, Amount = dataContract.Amount }); }
/// <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)); } }