Esempio n. 1
0
        public FullMenuViewModel(FullMenuPage page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            Items = new ObservableCollection <Dish>(_canteenService.GetFullMenuAsync());
        }
Esempio n. 2
0
        /// <summary>
        /// Конструктор модели представления Всех моих заказов
        /// </summary>
        /// <param name="page">Связанная страница (предсмтавление)</param>
        public OrderHistoryViewModel(OrderHistoryPage page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            _refreshOrders = false;
            MessagingCenter.Subscribe <DayMenuViewModel, DateTime>(
                this, "Refresh Order",
                async(sender, arg) =>
            {
                _refreshOrders = true;
                await _page.DisplayAlert("Message received", "arg=" + arg, "OK");
            }
                );
            MessagingCenter.Subscribe <SettingsViewModel>(
                this, "Refresh Order",
                async(sender) =>
            {
                _refreshOrders = true;
                await _page.DisplayAlert("Message received", "From Settings Page", "OK");
            }
                );

            Items = new ObservableCollection <Order>();

            LoadItemsCommand.Execute(null);
        }
Esempio n. 3
0
        public CurrentMenuViewModel(CurrentMenuPage page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            _currentMenuDTO = (List <DayMenuDTO>)_canteenService.GetCurrentMenuAsync();

            _currentMenu = new List <DayMenu>();
            foreach (var item in _currentMenuDTO)
            {
                _currentMenu.Add(new DayMenu(item));
            }
            var dishTypes = _canteenService.GetDishTypesAsync();

            foreach (var item in _currentMenu)
            {
                var dayMenuId  = item.Id;
                var dishIdList = _canteenService.GetDishIdListAsync(dayMenuId);
                item.Dishes = new List <Dish>();
                foreach (var dishId in dishIdList)
                {
                    var dishDTO = _canteenService.GetDishByIdAsync(dishId);
                    dishDTO.Type = dishTypes[dishDTO.TypeId];
                    item.Dishes.Add(dishDTO);
                }
            }
            CurrentMenu = new ObservableCollection <DayMenu>(_currentMenu);
        }
Esempio n. 4
0
        public CurrentMenu2ViewModel(CurrentMenu2Page page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            _currentList = _canteenService.GetMenuOrderListAsync();
            CurrentList  = new ObservableCollection <MenuOrder>(_currentList);
        }
Esempio n. 5
0
        public CurrentMenu3ViewModel(Page page)
        {
            _page           = page;
            _canteenService = DependencyService.Get <CanteenDemoService>();

            var list1 = _canteenService.GetMenuOrderListAsync();
            var list2 = _canteenService.GetMenuOrderListAsync();

            CurrentList = new ObservableCollection <MenuOrderList>();
            CurrentList.Add(new MenuOrderList {
                WeekList = new ObservableCollection <MenuOrder>(list1)
            });
            CurrentList.Add(new MenuOrderList {
                WeekList = new ObservableCollection <MenuOrder>(list2)
            });
            CurrentList.Add(new MenuOrderList {
                WeekList = null
            });
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 /// <summary>
 /// Конструктор модели представления Текущего меню
 /// </summary>
 /// <param name="page">Связанная страница (представление)</param>
 public SettingsViewModel(SettingsPage page)
 {
     _page           = page;
     _canteenService = DependencyService.Get <CanteenDemoService>();
 }