Ejemplo n.º 1
0
        public StoreProductResponse StoreProduct(StoreProductRequest request)
        {
            StoreProductResponse     response = new StoreProductResponse();
            ProductBusinessComponent bc       = DependencyInjectionHelper.GetProductBusinessComponent();

            Product product = ProductAdapter.DtoToProduct(request.Product);

            response.Id = bc.StoreProduct(product);

            return(response);
        }
Ejemplo n.º 2
0
        public void TestDtoToProduct()
        {
            ProductDTO dto = new ProductDTO()
            {
                Id = 1, Name = "FakeProduct", Category = "FakeCategory", ListUnitPrice = (decimal)123.21, QuantityPerUnit = 100.2, ProductNumber = "FakeProductNumber", UnitsOnStock = 10, Version = 0
            };

            Assert.AreEqual(true, dto.IsValid);

            Product product = ProductAdapter.DtoToProduct(dto);

            Assert.AreEqual <int>(product.ProductId, dto.Id);
            Assert.AreEqual <string>(product.Name, dto.Name);
            Assert.AreEqual <string>(product.Category, dto.Category);
            Assert.AreEqual(product.Version, dto.Version);
            Assert.AreEqual <double>(product.QuantityPerUnit, dto.QuantityPerUnit);
            Assert.AreEqual <decimal>(product.ListUnitPrice, dto.ListUnitPrice);
            Assert.AreEqual(true, dto.IsValid);
        }