public async void LoadProducts()
        {
            try
            {
                var products = await _productServiceAgent.GetProducts();

                Products = new List <Product>(products);
            }
            catch (Exception ex)
            {
                NotifyError(null, ex);
            }
        }
示例#2
0
        public IEnumerable <Product> GetProducts(string sortOption)
        {
            SortOption sortBy;

            if (string.IsNullOrWhiteSpace(sortOption))
            {
                throw new ArgumentNullException(nameof(sortOption));
            }

            if (!Enum.TryParse(sortOption, true, out sortBy))
            {
                throw new ArgumentException(nameof(sortOption));
            }

            var products = _productServiceAgent.GetProducts();
            var store    = new WooliesStore();

            store.Load(products);
            return(store.SortBy(SimpleSortFactory.Create(sortBy)));
        }