コード例 #1
0
        //Add Outings
        private void AddOutingToList()
        {
            Console.Clear();
            Console.WriteLine("Please select the type of outing you wish to add to: \n" +
                              "1. Golf\n" +
                              "2. Bowling\n" +
                              "3. Amusement Park\n" +
                              "4. Concert");
            string outingInput = Console.ReadLine();

            if (outingInput == "1" || outingInput == "2" || outingInput == "3" || outingInput == "4")
            {
                Console.WriteLine("Please enter the name of this outing.");
                string name = Console.ReadLine();
                Console.WriteLine("Please enter the total people attending this outing.");
                int peopleAttending = int.Parse(Console.ReadLine());
                Console.WriteLine("Please enter the date of this outing. Use formatting as such: (YYYY, MM, DD)");
                DateTime dateOnly  = DateTime.Parse(Console.ReadLine());
                DateTime dateEntry = dateOnly.Date;
                Console.WriteLine("Please enter the cost per person for this outing.");
                decimal           costPerPerson = decimal.Parse(Console.ReadLine());
                int               outingParse   = int.Parse(outingInput);
                Outing.OutingType outingType    = (Outing.OutingType)Enum.ToObject(typeof(Outing.OutingType), outingParse);

                Outing newOuting = new Outing(name, peopleAttending, dateEntry, costPerPerson, outingType);
                if (_outingsRepository.AddOuting(newOuting) == true)
                {
                    Console.WriteLine("The outing '" + (name) + "' has been added.");
                }
            }
            else
            {
                Console.WriteLine("Please choose a correct outing type.");
            }
        }