예제 #1
0
        private static void ShowAgencies(AgencyModel dbConnection)
        {
            Console.Clear();
            Console.WriteLine("List of Agencies:");

            var agenecyies = dbConnection.Agency.ToList();

            for (int i = 0; i < agenecyies.Count; i++)
            {
                Console.WriteLine("------------------------------");
                Console.WriteLine("Agency Id: " + agenecyies[i].Id);
                Console.WriteLine("Agency Name: " + agenecyies[i].Name);
                Console.WriteLine("Email: " + agenecyies[i].eMail);
            }
        }
예제 #2
0
        private static void DestinationCreation(AgencyModel dbConnection)
        {
            Console.WriteLine("____________________________");
            Console.WriteLine("Create a new destination!");
            var addDestination = new Destination();

            Console.WriteLine("Register a city: ");
            addDestination.City = Console.ReadLine();

            Console.WriteLine("Register a Country: ");
            addDestination.Country = Console.ReadLine();
            dbConnection.Destination.Add(addDestination);
            dbConnection.SaveChanges();
            Console.WriteLine("The information has been saved on the database!");
        }
예제 #3
0
        private static void ShowTravelers(AgencyModel dbConnection)
        {
            Console.WriteLine("____________________________________");
            Console.WriteLine("List of travelers:");
            Console.WriteLine("____________________________________");
            var travelers = dbConnection.Travelers.ToList();

            for (int i = 0; i < travelers.Count; i++)
            {
                Console.WriteLine("------------------------------");
                Console.WriteLine("Traveler id: " + travelers[i].Id);
                Console.WriteLine("Name: " + travelers[i].Name);
                Console.WriteLine("Travels with AgencyId: " + travelers[i].AgencyID);
                Console.WriteLine("Destination Id: " + travelers[i].DestinationID);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            using (AgencyModel dbConnection = new AgencyModel())
            {
                // Update Traveler
                var selectedUpTraveler = dbConnection.Travelers.Where(f => f.Name == "Delil").FirstOrDefault();
                // Here you choose which Traveler you want to change
                // In this case we change Delil to Bkörn
                if (selectedUpTraveler != null)
                {
                    selectedUpTraveler.Name = "Björn";

                    dbConnection.SaveChanges();
                }

                // Update Destination
                var selectedUpDestination = dbConnection.Destination.Where(p => p.Country == "Turkey").FirstOrDefault();
                // Here you choose which counry and city you would like to change
                // In this case we change Turkey to Sweden and östersund as city
                if (selectedUpDestination != null)
                {
                    selectedUpDestination.Country = "Sweden";    // County changes
                    selectedUpDestination.City    = "Östersund"; // City C changes
                    dbConnection.SaveChanges();
                    // Note that sometimes there is same country name with different city in the destination list
                }

                bool listRunning = true;
                while (listRunning)
                {
                    char ch;

                    ShowMenu();

                    ch = Char.Parse(Console.ReadLine());

                    switch (ch)
                    {
                    case '1':
                        ShowAgencies(dbConnection);
                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();

                        break;

                    case '2':
                        ShowTravelers(dbConnection);
                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();

                        break;

                    case '3':
                        ListOfDestinationsAndCreationOfTraveler(dbConnection);
                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();


                        break;

                    case '4':
                        DestinationCreation(dbConnection);

                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();
                        break;

                    case '5':
                        DeleteTraveler(dbConnection);
                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();

                        break;

                    case '6':
                        DeleteDestination(dbConnection);
                        Console.WriteLine("Press [ENTER] to go back to the menu");
                        Console.ReadLine();
                        Console.Clear();


                        break;
                    }
                }
            }
        }