예제 #1
0
        public FullMenuViewModel(FullMenuPage page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            Items = new ObservableCollection <Dish>(_canteenService.GetFullMenuAsync());
        }
예제 #2
0
        public FullMenuGroupedViewModel(FullMenuGroupedPage page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            Items = new ObservableCollection <Dish>(_canteenService.GetFullMenuAsync());
            var dishTypes = _canteenService.GetDishTypesAsync();

            foreach (var item in Items)
            {
                item.Type = dishTypes[item.TypeId];
            }
            var sorted = from item in Items
                         orderby item.TypeId
                         group item by item.Type.Plurals into itemGroup
                         select new Grouping <string, Dish>(itemGroup.Key, itemGroup);

            ItemsGrouped = new ObservableCollection <Grouping <string, Dish> >(sorted);
        }