Ejemplo n.º 1
0
 private ProductDto ToDto(ProductDataContract dataContract)
 {
     return(new ProductDto
     {
         Name = dataContract.Name,
         Price = dataContract.Price,
         Amount = dataContract.Amount
     });
 }
Ejemplo n.º 2
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));
            }
        }