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); }
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); }
/// <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)); }