コード例 #1
0
        private List <Product> SortProducts(List <Product> productList, string sortOption)
        {
            try
            {
                List <Product> sortedList = new List <Product>();
                switch (sortOption.ToLower())
                {
                case "low":
                    sortedList = ShoppingServicesUtil.SortProductsLowToHigh(productList);
                    return(sortedList);

                case "high":
                    sortedList = ShoppingServicesUtil.SortProductsHighToLow(productList);
                    return(sortedList);

                case "ascending":
                    sortedList = ShoppingServicesUtil.SortProductsAToZ(productList);
                    return(sortedList);

                case "descending":
                    sortedList = ShoppingServicesUtil.SortProductsZToA(productList);
                    return(sortedList);

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.StackTrace);
                throw;
            }
        }
コード例 #2
0
 private List <Product> SortProducts(List <CustomerShoppingHistory> customerShoppingHistoryList)
 {
     return(ShoppingServicesUtil.SortRecommendedProducts(customerShoppingHistoryList));
 }