public ClientMenuViewModel(User user, Reservation reservation, FastObservableCollection <OrderedDish> orderedDishes = null)
        {
            _user          = user;
            _reservation   = reservation;
            _rootViewModel = ViewModelManager.GetFirstOrDefaultInstance <MainWindowViewModel>();
            OrderedDishes.AutomaticallyDispatchChangeNotifications = true;
            // передаем в конструктор ссылку на собираемую коллекцию заказанных блюд
            _sumCalculator = new OrderedSumCalculator(OrderedDishes);

            AddCommand = new Command(OnAddCommandExecute);
            SelectionChangedCommand = new Command(OnSelectionChangedCommandExecute);
            DeleteCommand           = new Command(OnDeleteCommandExecute, OnDeleteCommandCanExecute);
            BackCommand             = new Command(OnBackCommandExecute);
            NextCommand             = new Command(OnNextCommandExecute, OnNextCommandCanExecute);

            RefreshDishesCollection();

            if (orderedDishes != null)
            {
                OrderedDishes = orderedDishes;
                TotalSum      = _sumCalculator.GetCurrentOrderedSum();
            }
            else
            {
                OrderedDishes.Clear();
            }
        }
        public ClientOrdersViewModel(IViewModel parentViewModel, User user)
        {
            _user                 = user;
            UserLogin             = _user.Login;
            _parentViewModel      = parentViewModel;
            _orderedSumCalculator = new OrderedSumCalculator(OrderedDishes);
            _rootViewModel        = ViewModelManager.GetFirstOrDefaultInstance <MainWindowViewModel>();

            BackCommand = new Command(OnBackCommandExecute);
            SelectAnotherOrderCommand = new Command(OnSelectAnotherOrderCommandExecute);
            DeleteOrderCommand        = new Command(OnDeleteOrderCommandExecute, OnDeleteOrderCommandCanExecute);

            RefreshOrdersWithReservationsCollection();
        }
Exemplo n.º 3
0
        public ClientTotalsViewModel(User user, Reservation reservation, FastObservableCollection <OrderedDish> orderedDishes)
        {
            OrderedDishes = orderedDishes;

            _user          = user;
            _reservation   = reservation;
            _sumCalculator = new OrderedSumCalculator(orderedDishes);

            _rootViewModel = ViewModelManager.GetFirstOrDefaultInstance <MainWindowViewModel>();

            BackCommand  = new Command(OnBackCommandExecute);
            OrderCommand = new Command(OnOrderCommandExecute);

            FillViewModelProperties();

            CheckBonus();
        }