Exemplo n.º 1
0
        public ActionResult SelectMenuItem(MenuItem menuItem)
        {
            var errorMessage = string.Empty;

            if (!GetCurrentItems().Contains(menuItem))
            {
                return(FailResult.Get($"Menu item not found"));
            }

            try
            {
                switch (menuItem)
                {
                case CommandMenuItem command:
                    var cmdParams   = command.GetParameters();
                    var paramValues = ReadParams(cmdParams);
                    return(command.Execute(paramValues));

                default:
                    currentItem = menuItem;
                    return(OkMenuResult.Get());
                }
            }
            catch (Exception ex)
            {
                errorMessage            = ex.Message;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Something goes wrong");
                Console.ResetColor();
            }

            return(FailResult.Get(errorMessage));
        }
Exemplo n.º 2
0
        public ActionResult NavigateTo(MenuItem menuItem)
        {
            if (Items.Contains(menuItem))
            {
                return(OkMenuResult.Get());
            }

            var message = $"Wrong menu item '{menuItem.Name}'";

            return(FailResult.Get(message));
        }