コード例 #1
0
        public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
        {
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                IList<Model.Product> productEntities = _productService.GetAllProductsFor(productListRequest.CustomerType);

                productListResponse.Products = productEntities.ConvertToProductListViewModel();
                productListResponse.Success = true;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                // Log the exception...
                Console.WriteLine(ex.Message);
                productListResponse.Success = false;
                // Return a friendly error message
                productListResponse.Message = "Check that your database is in the correct place. Hint: Check the AttachDbFilename section within App.config in the project ASPPatterns.Chap3.Layered.Repository." + ex.Message;
            }
            catch (Exception ex)
            {
                // Log the exception...

                productListResponse.Success = false;
                // Return a friendly error message
                productListResponse.Message = "An error occured";
            }

            return productListResponse;
        }
コード例 #2
0
        public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
        {
            //客户端发了一个请求,此时创建一个响应集合
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                //为全部商品赋予指定的折扣策略
                IList <Model.Product> productEntities = _productService.GetAllProductsFor(productListRequest.CustomerType);

                productListResponse.Products = productEntities.ConvertToProductListViewModel();
                productListResponse.Success  = true;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                // Log the exception...

                productListResponse.Success = false;
                // Return a friendly error message
                productListResponse.Message = "Check that your database is in the correct place. Hint: Check the AttachDbFilename section within App.config in the project ASPPatterns.Chap3.Layered.Repository.";
            }
            catch (Exception ex)
            {
                // Log the exception...

                productListResponse.Success = false;
                // Return a friendly error message
                productListResponse.Message = "An error occured";
            }

            return(productListResponse);
        }
コード例 #3
0
        public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
        {
            var productListResponse = new ProductListResponse();

            try
            {
                var products = _productService.GetAllProductsFor(productListRequest.CustomerType);
                productListResponse.Products = products.ConvertToProductListViewModel();
                productListResponse.Success  = true;
            }
            catch (Exception exception)
            {
                //TODO LOG EXCEPTION
                productListResponse.Success = false;
                productListResponse.Message = "An error occured!";
            }
            return(productListResponse);
        }
コード例 #4
0
        public ProductListResponse GetAllProductsFor(ProductListRequest request)
        {
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                IList <Product> productEntities = _productService.GetAllProductsFor(request.CustomerType);
                productListResponse.products = productEntities.ConvertToProductListViewModel();
                productListResponse.Success  = true;
            }
            catch (Exception ex)
            {
                productListResponse.Success = false;
                productListResponse.Message = "An error ocurred";
            }

            return(productListResponse);
        }
コード例 #5
0
        public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
        {
            var productListResponse = new ProductListResponse();

            try
            {
                var productEntities = _productService.GetAllProductsFor(productListRequest.CustomerType);
                productListResponse.Products = productEntities.ConvertToProductListViewModel();
                productListResponse.Success = true;
            }
            catch (Exception)
            {
                productListResponse.Success = false;
                productListResponse.Message = "An error occurred";
            }

            return productListResponse;
        }
コード例 #6
0
ファイル: ProductService.cs プロジェクト: rendon75/chap3layer
        public ProductListResponse GetAllProductsFor(ProductListRequest productListRequest)
        {
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                IList<Model.Product> productEntities = _productService.GetAllProductsFor(productListRequest.CustomerType);
                productListResponse.Products = productEntities.ConvertToProductListViewModel();
                productListResponse.Sucess = true;
            }
            catch (Exception ex)
            {
                // Log the exception..
                productListResponse.Sucess = false;
                // Return a friendly error message
                productListResponse.Message = "An error occurred";
            }
            return productListResponse;
        }
コード例 #7
0
        public ProductListResponse GetAllProductsFor(
            ProductListRequest productListRequest)
        {
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                IList <Model.Product> productEntities =
                    _productService.GetAllProductsFor(productListRequest.CustomerType);
                productListResponse.Products = productEntities.ConvertToProductListViewModel();
                productListResponse.Success  = true;
            }
            catch (Exception)
            {
                // Log the exception…
                productListResponse.Success = false;
                // Return a friendly error message
                productListResponse.Message = "An error occurred";
            }

            return(productListResponse);
        }