Exemplo n.º 1
0
        public void AddCategory()
        {
            if (string.IsNullOrEmpty(CategoryName) || string.IsNullOrEmpty(CategoryDescription))
            {
                Message.Show("Some Fields are empty");
                return;
            }

            if (_menuManagerViewModel.Categories.Any(cat => cat.Name.Equals(CategoryName)))
            {
                Message.Show("There is category named: " + CategoryName);
                return;
            }

            var addingCategory = _menuDataModel.AddCategoryItem(CategoryName, CategoryDescription);

            if (addingCategory != null)
            {
                _menuManagerViewModel.AddCategoryToViewModel(addingCategory);
                _menuManagerViewModel.CloseDialogs();
                return;
            }

            Message.Show("Failed");

            return;
        }
        public void AddItem()
        {
            if (string.IsNullOrEmpty(MenuItemName) || string.IsNullOrEmpty(Price) ||
                string.IsNullOrEmpty(MenuItemDescription))
            {
                Message.Show("Some Fields are empty");
                return;
            }

            if (SelectedCategory == null)
            {
                Message.Show("No Category was selected");
                return;
            }

            if (_menuManagerViewModel.AllMenuItems.Any(cat => cat.Name.Equals(MenuItemName)))
            {
                Message.Show("There is menu item named: " + MenuItemName);
                return;
            }

            double price;

            if (!double.TryParse(Price, out price))
            {
                Message.Show("Price is wrong");
                return;
            }


            var addingMenuItem = _menuDataModel.AddMenuItem(MenuItemName, SelectedCategory, price, MenuItemDescription);

            if (addingMenuItem != null)
            {
                _menuManagerViewModel.AddNewMenuItem(addingMenuItem);
                _menuManagerViewModel.CloseDialogs();
                return;
            }

            Message.Show("Falied");
        }
        public void EditMenuItem()
        {
            if (string.IsNullOrEmpty(MenuItemName) || string.IsNullOrEmpty(Price) ||
                string.IsNullOrEmpty(MenuItemDescription))
            {
                Message.Show("Some Fields are empty");
                return;
            }

            if (SelectedCategory == null)
            {
                Message.Show("No Category was selected");
                return;
            }

            if (_menuManagerViewModel.AllMenuItems.Any(cat => (cat.Name.Equals(MenuItemName) && cat.Id != _menuItem.Id)))
            {
                Message.Show("There is menu item named: " + MenuItemName);
                return;
            }

            double price;

            if (!double.TryParse(Price, out price))
            {
                Message.Show("Price is wrong");
                return;
            }

            var result = _menuDataModel.EditMenuItem(_menuItem, MenuItemName, price, SelectedCategory, MenuItemDescription);

            if (result)
            {
                _menuManagerViewModel.MenuItems.Refresh();
                _menuManagerViewModel.CloseDialogs();
            }
            else
            {
                Message.Show("Failed");
            }
        }
 private void CloseAllDialogs()
 {
     _menuManagerViewModel.CloseDialogs();
     _waiterManagerViewModel.CloseDialogs();
     _tableManagerViewModel.CloseDialogs();
 }