コード例 #1
0
        /// <summary>
        /// Gets Product data by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ProductDTO GetById(int id)
        {
            if (id < 1)
            {
                // Throw Business logic exception here. Throwing new Exception to cover -ve case in unit test for illustration.
                throw new Exception("Business logic Exception with status code.");
            }

            var product = _productDataProvider.GetById(id);

            return(_mapper.Map <Product, ProductDTO>(product));
        }