Ejemplo n.º 1
0
        public ItemDetailViewModel(MenuItems newMenuItem)
        {
            menuDatabase = new MenuDatabase(); //the menu database is initialised

            databaseModel = new DatabaseModel();
            connection    = databaseModel.GetConnection();



            AddMenuItemCommand        = new Command(async() => await AddToBasket());
            MinusButtonPressedCommand = new Command(async() => await MinusButtonPressed());
            PlusButtonPressedCommand  = new Command(async() => await PlusButtonPressed());


            // since the page will be used for opening current menu items, the current MenuItems object will be
            //initialised with the newMenuItem paramater if one is passed through the program
            if (newMenuItem == null)
            {
                menuItem = new MenuItems();
            }
            else
            {
                menuItem = newMenuItem;
            }
        }
Ejemplo n.º 2
0
        public BasketPageViewModel()
        {
            // the messaging center is subscribed to the itemdetailviewmodel which will send items from there which the user has added to the basked
            // and once the items have been added, the OnMenuItemAdded method will be executed
            MessagingCenter.Subscribe <ItemDetailViewModel, MenuItems>(this, "MenuItemAdded", OnMenuItemAdded);
            menuDatabase = new MenuDatabase();

            databaseModel = new DatabaseModel();
            connection    = databaseModel.GetConnection();


            LoadOrdersCommand = new Command(async() => await LoadOrders());
        }
Ejemplo n.º 3
0
        public NewItemViewModel()
        {
            databaseModel = new DatabaseModel();           //the database model is created
            connection    = databaseModel.GetConnection(); //the connection is retrieved
            connection.CreateTableAsync <MenuItems>();     //a table of MenuItems is created in case one doesn't
                                                           // already exist

            menuDatabase = new MenuDatabase();             //the database of menu items is initialized

            menu = new MenuItems();                        //the menu object is initialised

            //
            SaveCommand   = new Command(async() => await OnSave());
            CancelCommand = new Command(OnCancel);
            //this.PropertyChanged +=
            //    (_, __) => SaveCommand.ChangeCanExecute();
            //
        }