예제 #1
0
        static void Main(string[] args)
        {
            GardenServiceClient serviceClient = new GardenServiceClient();
            List <Plant>        plants        = serviceClient.GetPlants().ToList();

            List <string> actions = new List <string>()
            {
                "--Help", "--Create", "--Select --{Name}", "Update --{Name} --{WaterNumberr}", "Remove --{Name}"
            };

            if (!args.Any())
            {
                Console.WriteLine("No action requested!");
                Console.WriteLine("Use one of the following");
                foreach (string ac in actions)
                {
                    Console.WriteLine(ac);
                }
            }
            else
            {
                switch (args[0])
                {
                case "--Help":
                    ListActions(actions);
                    break;

                case "--Create":
                    AddPlant(serviceClient);
                    break;

                case "--Select":
                    ViewPlant(serviceClient, plants, args[1]);
                    break;

                case "--Update":
                    UpdatePlant(serviceClient, plants, args[1], args[2]);
                    break;

                case "--Remove":
                    RemovePlant(serviceClient, plants, args[1]);
                    break;
                }
            }


            Console.ReadKey();
        }