Exemple #1
0
        // public IMenuType getMenu(string menuName)
        // {
        //     if(!menuNames.Contains(menuName)) throw new MenuDoesNotExistException("Menu doesn't exist in the MenuManager!");
        //
        //     return menus[menuName];
        // }

        public void restorePreviousMenu()
        {
            if (MenuNames.Count == 1)
            {
                throw new MenuStackEmptyException("There is no menu to revert to!");
            }

            MenuNames.Pop();
            CurrentMenu = Menus[MenuNames.Peek()];
        }
Exemple #2
0
        public void setCurrentMenu(string menuName)
        {
            if (!menuExists(menuName))
            {
                throw new MenuDoesNotExistException("The given menu does not exist!");
            }

            MenuNames.Push(menuName);
            CurrentMenu = Menus[menuName];
        }
Exemple #3
0
        /// <summary>
        /// Resets the form and data.
        /// </summary>
        private void ResetFormAndData()
        {
            txtMenuTypeName.Text = string.Empty;
            txtDescription.Text = string.Empty;

            _menuType = null;
            MenuTypeId = null;

            txtMenuTypeName.Focus();
        }
Exemple #4
0
        public void addMenu(string menuName, IMenuType menuToAdd)
        {
            if (MenuNames.Contains(menuName))
            {
                return;
            }

            Menus.Add(menuName, menuToAdd);
            MenuNames.Push(menuName);
            CurrentMenu = menuToAdd;
        }
Exemple #5
0
        public IMenuType createMenu(MenuTypes type, IEnumerable <MenuItem> menuItems)
        {
            //Create IMenuType ready to initialise with the correct menu
            IMenuType menu = null;
            //Used to stop multiple enumeration error (though I shouldn't have to worry about that personally)
            var enumerable = menuItems.ToList();

            //Iterate through each menu item. If any are null, empty "", or whitespace " ... ", then throw an exception
            //to alert the user that their input is not valid
            foreach (var s in enumerable.Where(s => string.IsNullOrEmpty(s.menuItem) || string.IsNullOrWhiteSpace(s.menuItem)))
            {
                throw new ArgumentException($"The passed values contain a value which is not valid, '{s}'! Correct this erroneous value before continuing");
            }

            //Now pattern match the input against all the menu types to instantiate the correct menu
            switch (type)
            {
            case MenuTypes.NUMBERED_HORIZONTAL:
                menu = new NumberedHorizontal(enumerable);
                break;

            case MenuTypes.NUMBERED_VERTICAL:
                menu = new NumberedVertical(enumerable);
                break;

            case MenuTypes.ANGLE_HORIZONTAL:
                break;

            case MenuTypes.ANGLE_VERTICAL:
                break;

            case MenuTypes.SQUARE_HORIZONTAL:
                break;

            case MenuTypes.SQUARE_VERTICAL:
                break;

            default:
                throw new Exception("Menu type not coded for");
            }

            return(menu);
        }
Exemple #6
0
        public override bool SaveCommand(ref string message)
        {
            ResetErrorProvider();
            bool isValid = true;

            string menuTypeName = txtMenuTypeName.Text;
            string description = txtDescription.Text;


            // validate first
            // firstname
            if (string.IsNullOrEmpty(menuTypeName))
            {
                isValid = false;
                errorProviderMenuType.SetError(txtMenuTypeName, "Menu Type Name is required");
            }
            // then save
            if (isValid)
            {
                try
                {
                    if (_menuType == null) // new (add)
                    {
                        _menuType = this.BrokerFactory.SalesOrderBroker.CreateMenuTypeInstance();
                    }
                    _menuType.MenuTypeName = menuTypeName;
                    _menuType.MenuTypeDescription = description;

                    _menuType = this.BrokerFactory.SalesOrderBroker.SaveMenuType(_menuType, MembershipHelper.CurrentUserName);
                    message = "Menu type has been saved successfully";
                }
                catch (Exception ex)
                {
                    isValid = false;
                    message = ex.Message;
                }
            }
            return isValid;
        }
Exemple #7
0
        private void PopulateData()
        {

            // if edit then fill menu type object
            if (MenuTypeId.HasValue && MenuTypeId.Value > 0)
            {
                _menuType = this.BrokerFactory.SalesOrderBroker.GetMenuTypeById(MenuTypeId.GetValueOrDefault(-1));

                if (_menuType != null)
                {
                    txtDescription.Text = _menuType.MenuTypeDescription;
                    txtMenuTypeName.Text = _menuType.MenuTypeName;
                }

            }

        }
 /// <summary>
 /// Deletes the type of the menu.
 /// </summary>
 /// <param name="menuType">Type of the menu.</param>
 /// <param name="deletedBy">The deleted by.</param>
 /// <returns></returns>
 public abstract void DeleteMenuType(IMenuType menuType, string deletedBy);
 /// <summary>
 /// Saves the type of the menu.
 /// </summary>
 /// <param name="menuType">Type of the menu.</param>
 /// <param name="createdOrModifiedBy">The created or modified by.</param>
 /// <returns></returns>
 public abstract IMenuType SaveMenuType(IMenuType menuType, string createdOrModifiedBy);