Ejemplo n.º 1
0
        public HttpResponseMessage PostProduct(ProductViewModel productModel)
        {
            var prodContext = Mapper.Map <DataLayer.Product>(productModel);

            prodContext = _buildModelsService.CreateNewProduct(prodContext);
            var returnProduct = Mapper.Map <ProductViewModel>(prodContext);

            return(ReturnResponse(returnProduct, new JsonMediaTypeFormatter(), "application/json", HttpStatusCode.Created, string.Empty));
        }
Ejemplo n.º 2
0
        public void Delete_Product()
        {
            //Arrange
            var productName = "Deleted Sause";
            var productID   = 0;
            // We will create the product first then check its there then delete it.
            var product = new Product
            {
                ProductName  = productName,
                UnitPrice    = 2,
                SupplierID   = 1,
                CategoryID   = 1,
                UnitsInStock = 100
            };

            //Act
            var productCreated = buildModels.CreateNewProduct(product);

            productID = productCreated.ProductID;

            //Assert
            buildModels.DeleteProduct(productID).Should().Be(1);
        }