public FullMenuViewModel(FullMenuPage page) { _page = page; _canteenService = DependencyService.Get <CanteenDemoService>(); Items = new ObservableCollection <Dish>(_canteenService.GetFullMenuAsync()); }
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); }