예제 #1
0
        public void Run()
        {
            _outings = _outingRepo.GetList();

            while (_response != 5)
            {
                PrintMenu();
                switch (_response)
                {
                case 1:
                    _console.WriteLine($"List of Outings\n\nOuting Type\tNumber Of People\tDate of Outing\t\tCost per Person\t\tTotal Cost");
                    foreach (Outing thisOuting in _outings)
                    {
                        _console.WriteLine($"{thisOuting.Category}\t\t{thisOuting.NumPpl} \t\t\t{thisOuting.DateOfEvent}\t\t${thisOuting.PerPersonCost}\t\t\t${thisOuting.TotalEventCost}");
                    }
                    break;

                case 2:
                    _console.WriteLine("Enter outing category: Golf = 1, Bowling = 2, Amusment Park = 3, Concert = 4, Other = 5");
                    int categoryInt = int.Parse(_console.ReadLine());
                    _type = _outingRepo.EventTypeSwitch(categoryInt);

                    _console.WriteLine("How manny people attended the event?");
                    var numPpl = int.Parse(_console.ReadLine());

                    _console.WriteLine("When was the event? mm/dd/yyyy");
                    var eventDate = _console.ReadLine();

                    _console.WriteLine("What was the cost per person?");
                    var    perPersonCost = decimal.Parse(_console.ReadLine());
                    var    totalCost     = perPersonCost * numPpl;
                    Outing outing        = new Outing(_type, numPpl, eventDate, perPersonCost, totalCost);

                    _outingRepo.AddToList(outing);
                    break;

                case 3:
                    _console.WriteLine("Enter desired outing type: Golf = 1, Bowling = 2, Amusment Park = 3, Concert = 4, Other = 5");
                    var desiredType = int.Parse(_console.ReadLine());
                    var outingType  = _outingRepo.EventTypeSwitch(desiredType);
                    _outingRepo.AddOutingToListByType(outingType);
                    _console.WriteLine("Total cost of desired outing = " + _outingRepo.ReturnDesiredCostByType());
                    break;

                case 4:
                    decimal sum = 0;
                    foreach (Outing thisOuting in _outings)
                    {
                        sum += thisOuting.TotalEventCost;
                    }
                    _console.WriteLine("The outstanding total cost is: $" + sum);
                    break;

                case 5:
                    break;

                default:
                    _console.WriteLine("Please enter a correct value.");
                    break;
                }
                _console.WriteLine("Press any key to continue ...");
                _console.ReadKey();
            }
        }