示例#1
0
        public override async Task <List <Item> > getItems()
        {
            List <ItemDomainCatalog> itemCatalogList = null;

            var result = AppStorage.GetCatalogBrowseMode();

            if (result == Services.CdbMobileAppStorage.BrowseMode.Favorites)
            {
                Title = getTitle() + " (Favorites)";
                try
                {
                    itemCatalogList = await itemApi.GetFavoriteCatalogItemsAsync();

                    if (itemCatalogList == null)
                    {
                        FireViewModelMessageEvent("It seems that current user does not have favorites. Loading full list.");
                    }
                } catch (ApiException ex)
                {
                    // Unauthorized Exception
                    if (ex.ErrorCode == 401)
                    {
                        // Ignore unauthroized exception but notify user.
                        // To do, transfer message to view via event.
                        FireViewModelMessageEvent("Cannot Load Favorites. Please log in and try again.");
                    }
                    else
                    {
                        throw ex;
                    }
                    Debug.WriteLine(ex);
                }
            }

            if (itemCatalogList == null)
            {
                Title           = getTitle();
                itemCatalogList = await itemApi.GetCatalogItemsAsync();
            }

            List <Item> itemList = itemCatalogList.ConvertAll(x => (Item)x);

            return(itemList);
            //return await cdbRestApi.getCatalogItems();
        }