Beispiel #1
0
        /*--------Create Trip---------*/
        public void CreateTrip()
        {
            Trip trip = new Trip();
            Console.WriteLine("With what Name you want to call your Trip?");
            trip.TripName = Console.ReadLine();
            Console.WriteLine("Lets Describe About your Trip.");
            trip.Description = Console.ReadLine();
            trip.StartDate = CaptureDate("On which date started your Trip (dd-MM-yyyy)");
            trip.EndDate = CaptureDate("Your Trip End Date");

            /*-------------Expense details------------*/
            Console.WriteLine("Do you want to Add Expenses? (y/n)");
            while (Console.ReadLine().ToLower() == "y")
            {
                AddExpense(trip);

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.ResetColor();
                Console.WriteLine("Do you want to add another Expense? (y/n)");
            }
            trips.Add(trip);

            Console.WriteLine("Trip Added Successfully, Your Trip id is: " + trip.Id);
            DoYouWantToSave();
        }
Beispiel #2
0
        /*------New Expense-------*/
        public void AddExpense(Trip trip)
        {
            Console.Clear();
            Expense expense = new Expense();

            Console.WriteLine("enter expense Name");

            expense.ExpenseName = Console.ReadLine();

            Console.WriteLine("enter expense type");
            int i = 1;
            foreach (var item in Enum.GetNames(typeof(ExpenseType)))
            {
                Console.WriteLine(i + item);
                i++;
            }
            var option = Convert.ToInt16(Console.ReadLine());
            expense.ExpenseType = (ExpenseType)option;
            Console.WriteLine("Enter The Amount you Spend:");
            expense.Amount = Convert.ToDouble(Console.ReadLine());
            trip.Expenses.Add(expense);
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Expense Added Your Expense id is: " + expense.Id);
            Console.ResetColor();
        }