Beispiel #1
0
        public override void Execute(CommandSwitchValues values)
        {
            DateTime regtime = DateTime.Now;
            int cost = values.GetSwitchAsInt("-cost");
            string eventType = values.GetSwitch("-eventType");
            string status = values.GetOptionalSwitch("-status");
            string customerName = values.GetSwitch("-customerName");
            string customerEmail = values.GetSwitch("-customerEmail");
            int curentAmmount = values.GetSwitchAsInt("-currentAmmount");
            string customerPhoneNumber = values.GetSwitch("-customerPhoneNumber");

            string comment = values.GetOptionalSwitch("-comment");
            if(comment == null)
                comment = "-";

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.NewOrder(regtime,
                                        comment,
                                        eventType,
                                        customerName,
                                        customerEmail,
                                        customerPhoneNumber,
                                        cost,curentAmmount,
                                        status);
            }
        }
 public override void Execute(CommandSwitchValues values)
 {
     using (var orderController = ControllerFactory.MakeOrderController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayOrders(orderController.GetAllOrders());
     }
 }
 public override void Execute(CommandSwitchValues values)
 {
     using (var scriptController = ControllerFactory.MakeEventScriptController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayScripts(scriptController.GetAllScripts());
     }
 }
 public override void Execute(CommandSwitchValues values)
 {
     using (var imageController = ControllerFactory.MakeImageController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayImages(imageController.GetAllImages());
     }
 }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newNumber = values.GetSwitch("-newNumber");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeCustomersPhoneNumber(id, newNumber);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newCost = values.GetSwitchAsInt("-newCost");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeEventCost(id, newCost);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newType = values.GetSwitch("-newType");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.ChangeScriptType(id, newType);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScript(scriptController.GetScriptbyId(id));
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newDur = values.GetSwitchAsInt("-newDur");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.ChangeScriptDurration(id, newDur);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            string type = values.GetSwitch("-eventType");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayOrders(orderController.ViewOrdersWithSimilarEvent(type));
            }
        }
Beispiel #11
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newStatus = values.GetSwitch("-newStatus");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeStatus(id, newStatus);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayImages(imageController.ViewImagesWithSimilarName(name));
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newName = values.GetSwitch("-newName");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                imageController.ChangeImageName(id, newName);
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            string type = values.GetSwitch("-type");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScripts(scriptController.ViewScriptsWithSimilarType(type));
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScriptID(orderController.ShowAttachedScriptID(id));
            }
        }
Beispiel #16
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newAmmount = values.GetSwitchAsInt("-newAmmount");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                OrderInfo order = orderController.GetOrderbyId(id);
                int totalAmmount = order._currentAmmount + newAmmount;
                orderController.UpdateTotalAmmount(id, totalAmmount);
            }
        }
Beispiel #17
0
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");
            int dur = values.GetSwitchAsInt("-dur");
            string body = values.GetSwitch("-body");
            string eventType = values.GetSwitch("-eventType");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.NewScript(name,body,dur,eventType);
            }
        }
Beispiel #18
0
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");
            string description = values.GetOptionalSwitch("-description");
            string imageURL = values.GetSwitch("-imageURL");
            string eventType = values.GetSwitch("-eventType");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                imageController.NewImage(name, description, imageURL, eventType);
            }
        }
Beispiel #19
0
        public void ProcessCommandLine(string commandLine)
        {
            string[] parts = commandLine.Trim().Split(' ', '\t');
            if (parts.Length == 0)
                return;

            string commandName = parts[0];
            if (commandName.Length == 0)
                return;

            Command command;
            if (!commands.TryGetValue(commandName, out command))
                throw new Exception("CommandSyntax: unknown command");

            var values = new CommandSwitchValues();
            for (int i = 1; i < parts.Length; i++)
            {
                string switchName = parts[i];
                CommandSwitch sw = command.FindSwitch(switchName);
                if (sw == null)
                    throw new Exception("CommandSyntax: unsupported switch " + switchName);

                switch (sw.Mode)
                {
                    case CommandSwitch.ValueMode.Unexpected:
                        values.SetSwitch(switchName, "true");
                        break;

                    case CommandSwitch.ValueMode.ExpectSingle:
                        values.SetSwitch(switchName, parts[i + 1]);
                        ++i;
                        break;

                    case CommandSwitch.ValueMode.ExpectMultiple:
                        values.AppendSwitch(switchName, parts[i + 1]);
                        ++i;
                        break;

                    default:
                        throw new Exception("CommandSyntax: unexpected switch value mode");
                }
            }

            foreach (string switchName in command.SwitchNames)
            {
                CommandSwitch sw = command.FindSwitch(switchName);
                if (!sw.Optional && !values.HasSwitch(switchName))
                    throw new Exception("CommandSyntax: switch " + switchName + " must be specified.");
            }

            command.Execute(values);
        }
Beispiel #20
0
        public override void Execute(CommandSwitchValues values)
        {
            string commandName = values.GetOptionalSwitch("-command");
            if (commandName != null)
            {
                Command command = handler.FindCommand(commandName);
                if (command == null)
                    throw new Exception("help: command " + commandName + " not found");

                ShowHelpFor(command);
            }

            else
            {
                foreach (string name in handler.CommandNames)
                    ShowHelpFor(handler.FindCommand(name));
            }
        }
        public override void Execute(CommandSwitchValues values)
        {
            int orderid = values.GetSwitchAsInt("-orderid");
            if (orderid <= 0)
                throw new SystemException("ID value must be more than 0");

            int scriptid = values.GetSwitchAsInt("-scriptid");
            if (scriptid <= 0)
                throw new SystemException("ID value must be more than 0");

            using(var scriptController = ControllerFactory.MakeEventScriptController())
            {
                if (scriptController.ScriptExist(scriptid))
                {
                    using (var orderController = ControllerFactory.MakeOrderController())
                    {
                        ReportGenerator generator = new ReportGenerator(Console.Out);
                        orderController.AttachScriptID(orderid, scriptid);
                        Console.WriteLine("Success!");
                    }
                }
            }
        }
Beispiel #22
0
 public override void Execute(CommandSwitchValues values)
 {
     Output.WriteLine("Good Bye!");
     Environment.Exit(0);
 }