public bool AddOutting(Outting outting)
        {
            int startingCount = _outtingDirectory.Count;

            _outtingDirectory.Add(outting);
            bool wasAdded = (_outtingDirectory.Count > startingCount);

            return(wasAdded);
        }
Beispiel #2
0
        private void AddOutting()
        {
            Console.Clear();
            Console.WriteLine("You chose to add an outting.\n\n" +
                              "What was the type of outting?\n\n" +
                              "1. Golf\n" +
                              "2. Bolwing\n" +
                              "3. Amusement Park\n" +
                              "4. Concert\n\n" +
                              "5. Go back\n\n");
            string      typeInputString = Console.ReadLine();
            OuttingType type            = 0;

            switch (typeInputString)
            {
            case "1":
                type = OuttingType.Golf;
                break;

            case "2":
                type = OuttingType.Bowling;
                break;

            case "3":
                type = OuttingType.AmusementPark;
                break;

            case "4":
                type = OuttingType.Concert;
                break;

            case "5":
                RunMenu();
                break;

            default:
                break;
            }

            Console.WriteLine("\nHow many people attended this event?\n\n");
            string attendanceString = Console.ReadLine();
            int    numberOfPeople   = Convert.ToInt32(attendanceString);

            Console.WriteLine("\nIn mm/dd/yyy, on what date did this event occur?\n\n");
            string   dateString = Console.ReadLine();
            DateTime date       = DateTime.Parse(dateString);

            Console.WriteLine("\nHow much did the event cost?");
            string totalCostString = Console.ReadLine();
            double totalCost       = Convert.ToDouble(totalCostString);

            double costPerPerson = totalCost / numberOfPeople;

            Outting newOutting = new Outting(type, numberOfPeople, date, costPerPerson, totalCost);
            bool    wasAdded   = _repo.AddOutting(newOutting);

            if (wasAdded)
            {
                Console.WriteLine("Your outting has been added!");
            }
            else
            {
                Console.WriteLine("Unfortunately there was an error. Please try again.");
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }