public void Run()
        {
            while (isRunning)
            {
                string        input   = Menu();
                List <Outing> outings = outingRepo.GetOutings();
                switch (input)
                {
                case "1":
                    Console.WriteLine("Event Type\t" +
                                      "Attended\t" +
                                      "Date\t\t" +
                                      "Total Cost\t" +
                                      "Cost per Person");
                    foreach (Outing outing in outings)
                    {
                        Console.WriteLine(outing);
                    }
                    break;

                case "2":
                    Outing _outing = AddOuting();
                    outingRepo.AddOutings(_outing);
                    Console.Clear();
                    break;

                case "3":
                    Console.WriteLine("Which total cost would you like to view?\n" +
                                      "1. Total Cost of all outings\n" +
                                      "2. Total Cost of each outing type\n");
                    string input3 = Console.ReadLine();
                    Console.Clear();

                    switch (input3)
                    {
                    case "1":
                        decimal total = outingRepo.TotalCost(outings);
                        Console.WriteLine($"The total cost of all outings is: {total}");
                        Console.WriteLine("\nPress Enter to continue...");
                        Console.ReadLine();
                        Console.Clear();
                        break;

                    case "2":
                        EventTypes eventType = new EventTypes();
                        bool       isRunning = true;
                        while (isRunning)
                        {
                            Console.WriteLine("Select Event Type\n" +
                                              "1. Golf\n" +
                                              "2. Bowling\n" +
                                              "3. Amusement Park\n" +
                                              "4. Concert\n");
                            string typeInput = Console.ReadLine();
                            Console.Clear();
                            switch (typeInput)
                            {
                            case "1":
                                eventType = EventTypes.Golf;
                                isRunning = false;
                                Console.Clear();
                                break;

                            case "2":
                                eventType = EventTypes.Bowling;
                                isRunning = false;
                                Console.Clear();
                                break;

                            case "3":
                                eventType = EventTypes.Park;
                                isRunning = false;
                                Console.Clear();
                                break;

                            case "4":
                                eventType = EventTypes.Concert;
                                isRunning = false;
                                Console.Clear();
                                break;

                            default:
                                Console.WriteLine("Error: Select defined option");
                                break;
                            }
                        }
                        decimal totalC = outingRepo.TotalCostByType(outings, eventType);
                        Console.WriteLine($"The total cost of all {eventType} outings is: {totalC}");
                        Console.WriteLine("\nPress any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    default:
                        break;
                    }
                    break;

                case "4":
                    isRunning = false;
                    break;

                default:
                    break;
                }
            }
        }
        public void Run()
        {
            var initOuting = new List <Outing>()
            {
                new Outing(EventTypes.Park, 30, _outingRepo.StringToDateTime("6/5/2018"), 400.00m),
                new Outing(EventTypes.Bowling, 12, _outingRepo.StringToDateTime("2/15/2018"), 120.00m),
                new Outing(EventTypes.Concert, 67, _outingRepo.StringToDateTime("4/20/2018"), 700.00m),
                new Outing(EventTypes.Golf, 1, _outingRepo.StringToDateTime("12/25/2018"), 50.00m)
            };

            _outingRepo.AddOutings(initOuting);

            while (loop)
            {
                string        input   = ConsoleMenu();
                List <Outing> outings = _outingRepo.GetOutings();
                switch (input)
                {
                case "1":
                    Console.WriteLine("Event Type\t" +
                                      "Atendees\t" +
                                      "Date\t\t" +
                                      "Total Cost\t" +
                                      "Cost per Person");
                    foreach (Outing outing in outings)
                    {
                        Console.WriteLine(outing);
                    }
                    break;

                case "2":
                    Outing _outing = AddOuting();
                    _outingRepo.AddOutings(_outing);
                    Console.Clear();
                    break;

                case "3":
                    Console.WriteLine("What would you like to calculate?\n" +
                                      "[1] Total Cost across all outings\n" +
                                      "[2] Total Cost of each outing type\n");
                    System.ConsoleKeyInfo key = Console.ReadKey();
                    Console.Clear();
                    string answer = key.KeyChar.ToString();
                    switch (answer)
                    {
                    case "1":
                        decimal total = _outingRepo.TotalCost(outings);
                        Console.WriteLine("The total cost of all outings is: " + total);
                        Console.WriteLine("\nPress any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "2":
                        bool       trying    = true;
                        EventTypes eventType = new EventTypes();
                        while (trying)
                        {
                            Console.WriteLine("Select Event Type\n" +
                                              "[1] Golf\n" +
                                              "[2] Bowling\n" +
                                              "[3] Amusement Park\n" +
                                              "[4] Concert\n");
                            System.ConsoleKeyInfo kep = Console.ReadKey();
                            Console.Clear();
                            string response = kep.KeyChar.ToString();
                            switch (response)
                            {
                            case "1":
                                eventType = EventTypes.Golf;
                                trying    = false;
                                Console.Clear();
                                break;

                            case "2":
                                eventType = EventTypes.Bowling;
                                trying    = false;
                                Console.Clear();
                                break;

                            case "3":
                                eventType = EventTypes.Park;
                                trying    = false;
                                Console.Clear();
                                break;

                            case "4":
                                eventType = EventTypes.Concert;
                                trying    = false;
                                Console.Clear();
                                break;

                            default:
                                Console.WriteLine("Error: Select defined option");
                                break;
                            }
                        }
                        decimal totalt = _outingRepo.TotalCostByType(outings, eventType);
                        Console.WriteLine("The total cost of all " + eventType + " outings is: " + totalt);
                        Console.WriteLine("\nPress any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    default:
                        break;
                    }
                    break;

                case "X":
                    loop = false;
                    break;

                default:
                    break;
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            OutingRepository outingRepo = new OutingRepository();
            List <Outing>    outingList = outingRepo.GetList();

            string response = null;

            while (response != "4")
            {
                Console.Clear();
                Console.WriteLine($"What would you like to do? \n1. View all outings \n2. Create new outing \n3. Calculate costs \n4. Exit");
                response = Console.ReadLine();

                if (response == "1")
                {
                    Console.Clear();
                    if (outingList.Count == 0)
                    {
                        Console.WriteLine("There are currently no events recorded.");
                    }
                    else
                    {
                        foreach (Outing outing in outingList)
                        {
                            Console.WriteLine(outing);
                        }
                    }
                    Console.Read();
                }
                else if (response == "2")
                {
                    Console.Clear();
                    Console.WriteLine($"Select an outing type:\n" +
                                      $"1. Amusement Park\n" +
                                      $"2. Bowling\n" +
                                      $"3. Concert\n" +
                                      $"4. Golf");
                    int       input      = Int32.Parse(Console.ReadLine());
                    EventType newEvent   = EventType.AmusementPark;
                    string    typeHeader = null;
                    switch (input)
                    {
                    case 1:
                        newEvent   = EventType.AmusementPark;
                        typeHeader = "Amusement Park Event";
                        break;

                    case 2:
                        newEvent   = EventType.Bowling;
                        typeHeader = "Bowling Event";
                        break;

                    case 3:
                        newEvent   = EventType.Concert;
                        typeHeader = "Concert Event";
                        break;

                    case 4:
                        newEvent   = EventType.Golf;
                        typeHeader = "Golf Event";
                        break;

                    default:
                        Console.WriteLine("Invalid input");
                        break;
                    }
                    Console.Clear();
                    Console.WriteLine(typeHeader);
                    Console.Write("Enter the amount of attendees: ");
                    int attendance = Int32.Parse(Console.ReadLine());

                    Console.Write($"Enter the Month, Day, and Year of the event: " +
                                  $"\n Month (MM): ");
                    int newMonth = Int32.Parse(Console.ReadLine());
                    Console.Write(" Day (DD): ");
                    int newDay = Int32.Parse(Console.ReadLine());
                    Console.Write(" Year (YYYY): ");
                    int      newYear = Int32.Parse(Console.ReadLine());
                    DateTime date    = new DateTime(newYear, newMonth, newDay);

                    Console.Write("Enter the cost per individual for the event: $");
                    decimal individualCost = Decimal.Parse(Console.ReadLine());

                    Console.Write("Enter the total cost for the event: $");
                    decimal totalEventCost = Decimal.Parse(Console.ReadLine());

                    outingRepo.AddOuting(newEvent, attendance, date, individualCost, totalEventCost);

                    Console.Read();
                }
                else if (response == "3")
                {
                    Console.Clear();
                    Console.WriteLine($"What calculations would you like to do? \n1. Total costs for all outings \n2. Total oosts for outings of a specific type");
                    string calcResponse = Console.ReadLine();
                    if (calcResponse == "1")
                    {
                        Console.Clear();
                        Console.WriteLine($"Total cost for all outings: ${outingRepo.TotalCost()}");
                    }
                    else if (calcResponse == "2")
                    {
                        Console.Clear();
                        Console.WriteLine($"Enter the outing type would you like to sort by:" +
                                          $"\n1. Amusement Park" +
                                          $"\n2. Bowling" +
                                          $"\n3. Concert" +
                                          $"\n4. Golf");
                        var       typeNum = Int32.Parse(Console.ReadLine());
                        EventType type    = EventType.AmusementPark;
                        switch (typeNum)
                        {
                        case 1:
                            type = EventType.AmusementPark;
                            break;

                        case 2:
                            type = EventType.Bowling;
                            break;

                        case 3:
                            type = EventType.Concert;
                            break;

                        case 4:
                            type = EventType.Golf;
                            break;

                        default:
                            Console.WriteLine("Error");
                            break;
                        }
                        Console.Clear();
                        Console.WriteLine($"Total cost for {type}: ${outingRepo.GetCostByType(type)}");
                    }
                    Console.Read();
                }
                else if (response == "4")
                {
                    break;
                }
            }
        }