Example #1
0
        private void InitializeGroupedFooSource()
        {
            NoMoreGroupedFoos = false;
            groupedFooSource  = new GroupedFooSource(async(currentPage, itemsPerPage) =>
            {
                GroupedFooResponse response = null;
                try
                {
                    IsLoading = true;
                    response  = await fooService.GetGroupedFoos(currentPage, itemsPerPage);
                }
                catch (Exception ex)//Something completely unexpected happened, write a debug line to ensure persistence of the error
                {
                    //TODO ERROR HANDLING
                }
                finally
                {
                    IsLoading = false;//Hide the progressbar
                }
                return(response);
            });

            this.GroupedFoos = new IncrementalCollection <GroupedFooSource, GroupModel <string, Foo> >(groupedFooSource);
            this.GroupedFoos.HasMoreItemsChanged += (s, hasm) =>
            {
                this.NoMoreGroupedFoos = !hasm.HasMoreItems;
            };
        }
Example #2
0
        public async Task <GroupedFooResponse> GetGroupedFoos(int page, int items)
        {
            GroupedFooResponse response = new GroupedFooResponse();
            var fooResponse             = await GetFoos(page, items);

            var grouped = from f in fooResponse.Foos
                          group f by f.Category into g
                          select new GroupModel <String, Foo> {
                Key = g.Key, Items = g.ToList()
            };

            response.GroupedFoos  = grouped;
            response.HasMoreItems = fooResponse.HasMoreItems;
            return(response);
        }