Example #1
0
        void AdminstrationCommand(string[] commandlist) // I am aware that this collides with the requested dictionary definition, however i could simply not make it work
        {
            int argsCount = commandlist.Length;

            switch (commandlist[0]) // a switch over AdminCommands, this will if the commands are typed in a valid manner, and if it is, a relevant function will be called
            {
            case ":quit":           // if commands is either q or quit, UI.close will be called to effectivly end the session
            case ":q":
                if (argsCount == 1)
                {
                    UI.Close();
                }
                else
                {
                    UI.DisplayGeneralError("q or quit command can only be 1 arg");
                }
                break;

            case ":activate":     // if commands is either activate or deactivate, SetActiveStatus will be called in order to change the value of Product.Active
            case ":deactivate":
                if (argsCount == 2)
                {
                    pointsystem.SetActiveStatus(commandlist[0], commandlist[1]);
                }
                else
                {
                    UI.DisplayGeneralError("Command can only be 2 args: status and productID");
                }
                break;

            case ":crediton":     // If commands is either crediton or creditoff, SetCreditStatus will be called in order to change the value of Product.CanBeBoughtOnCredit
            case ":creditoff":
                if (argsCount == 2)
                {
                    pointsystem.SetCreditStatus(commandlist[0], commandlist[1]);
                }
                else
                {
                    UI.DisplayGeneralError("Command can only be 2 args: status and productID");
                }
                break;

            case ":addcredits":     // If addcredits helper function is called, and UI will load a new feedbackLine
                if (argsCount == 3)
                {
                    pointsystem.AddCreditsToAccount(commandlist[2], Int32.Parse(commandlist[1]));
                    UI.DisplayCreditsAdded(commandlist[2], Int32.Parse(commandlist[1]));
                }
                else
                {
                    UI.DisplayGeneralError("Command can only be 3 args, :addcredits, amount and user");
                }
                break;

            default:
                UI.DisplayAdminCommandNotFoundMessage(commandlist.ToString());     // command was not in a recoqnized format
                break;
            }
        }