Exemplo n.º 1
0
        public Product GetProduct(int id)
        {
            Product productBDO = null;

            try
            {
                productBDO = productController.GetProduct(id);
            }
            catch (Exception e)
            {
                var msg    = e.Message;
                var reason = "GetProduct Exception";
                throw new FaultException <ProductFault>
                          (new ProductFault(msg), reason);
            }

            if (productBDO == null)
            {
                var msg =
                    string.Format("No product found for id {0}",
                                  id);
                var reason = "GetProduct Empty Product";
                throw new FaultException <ProductFault>
                          (new ProductFault(msg), reason);
            }
            var product = new Product();

            TranslateProductBDOToProductDTO(productBDO, product);
            return(product);
        }
Exemplo n.º 2
0
        public void GetProductCtr()
        {
            var productCtr = new ProductCtr(new ProductCtrTestClass());
            var product    = new Product("The product name", 23.45m, "The product description", "The product catagory", "Img path");

            productCtr.AddProduct(product);
            var flag = productCtr.GetProduct(1);

            Assert.IsNotNull(flag);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Get a Product by id
 /// </summary>
 /// <param name="id"></param>
 /// <returns>
 /// Return Product if found, else null
 /// </returns>
 public Product GetProduct(int id)
 {
     return(ProductCtr.GetProduct(id));
 }