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