Exemplo n.º 1
0
        static void Menu(ref Flight[] arrival, ref Flight[] depature, ref Passenger[] people, ref List <FlightClass> f_class_list)
        {
            Console.Clear();
            do
            {
                Console.WriteLine("work with: \n1) flights \n2) flight classes \n3) exit");
                ConsoleKeyInfo case_switch = Console.ReadKey();
                switch (case_switch.Key.ToString())
                {
                case "D1":                                             //arrival
                    menu_flight(ref arrival, ref people, ref f_class_list);
                    break;

                //case "D2":
                //    menu_flight(ref depature, ref people, ref f_class_list);
                //    break;
                case "D2":
                    Console.WriteLine("\ninput the name of the flight class");
                    string name_f_class = Console.ReadLine();
                    int    cost         = 0;
                    do
                    {
                        Console.WriteLine("input the cost");
                        string cost_string  = Console.ReadLine();
                        bool   check_number = int.TryParse(cost_string, out cost);
                        if (cost == 0)
                        {
                            Console.WriteLine("input a number");
                        }
                    }while (cost == 0);
                    FlightClass f_class = new FlightClass(name_f_class, cost);
                    using (var ctx = new AirplaneContext())
                    {
                        ctx.FlightClasses.Add(f_class);
                        ctx.SaveChanges();
                    }
                    f_class_list.Add(f_class);
                    break;

                case "D3":
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("wrong input");
                    break;
                }
            } while (true);
        }
Exemplo n.º 2
0
        public void Delete_flight()
        {
            FlightEventArgs args = new FlightEventArgs();

            args.flight_number = this.flight_num;
            //FlightDeleteHandler(this, args);

            using (var ctx = new AirplaneContext())
            {
                ctx.Entry(this).State = EntityState.Deleted;
                ctx.SaveChanges();
            }
            this.Flight_num = string.Empty;
            this.City       = string.Empty;
            this.Airline    = string.Empty;
            this.Terminal   = string.Empty;
            this.Status     = string.Empty;
            this.Gate       = 0;
            this.arr_date   = DateTime.MinValue;
        }
Exemplo n.º 3
0
        public void Add_flight()
        {
            Console.SetCursorPosition(0, Console.CursorTop);
            do
            {
                Console.WriteLine("input the flight number, can not be empty");
                this.Flight_num = Console.ReadLine();
            } while (this.Flight_num == null);
            Console.WriteLine("input the city/port");
            this.City = Console.ReadLine();
            Console.WriteLine("input the airline");
            this.Airline = Console.ReadLine();
            Console.WriteLine("input the terminal");
            this.Terminal = Console.ReadLine();
            Console.WriteLine("choose the status");
            this.Status = Status_Choice();
            Console.ReadKey();
            int i = 0;

            do
            {
                Console.WriteLine("input the gate");
                string gate = Console.ReadLine();
                bool   s    = int.TryParse(gate, out i);
                this.Gate = i;
                if (i == 0)
                {
                    Console.WriteLine("gate must be a number");
                }
            }while (i == 0);
            this.arr_date = DateAndTime();
            using (var ctx = new AirplaneContext())
            {
                ctx.Flights.Add(this);
                ctx.SaveChanges();
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Console.WindowWidth, Console.WindowHeight + 3);

            var    flight_class_list = new List <FlightClass>();
            var    flights           = new List <Flight>();
            var    passengers        = new List <Passenger>();
            var    launcher          = new Launch();
            Thread thread_speech     = new Thread(launcher.Speech);
            Thread thread_launch     = new Thread(launcher.PlaneDrawing);
            var    c = flight_class_list.GetEnumerator();

            thread_speech.Start();
            thread_launch.Start();

            thread_launch.Join();
            using (var ctx = new AirplaneContext())
            {
                //FlightClass stud = new FlightClass() { Name = "Flight Class2", Cost = 20 };

                //ctx.FlightClasses.Add(stud);
                ////ctx.Passengers.Attach(stud);
                ////ctx.ObjectStateManager.ChangeObjectState(overlaydb1, EntityState.Modified);
                //ctx.SaveChanges();

                //Flight flight = new Flight() { Flight_num = "first", City = "Kyiv", Airline = "National Airlines", Terminal = "A", Status = "boarding", Gate = 12 };
                //ctx.Flights.Add(flight);
                ////ctx.Passengers.Attach(stud);
                ////ctx.ObjectStateManager.ChangeObjectState(overlaydb1, EntityState.Modified);

                // ctx.SaveChanges();
            }


            using (var context = new AirplaneContext())
            {
                flight_class_list = context.FlightClasses.ToList <FlightClass>();

                flights = context.Flights.ToList <Flight>();

                passengers = context.Passengers.ToList <Passenger>();
            }



            Console.ForegroundColor = ConsoleColor.Gray;

            Flight[]    arrival  = new Flight[30];
            Flight[]    depature = new Flight[30];
            Passenger[] people   = new Passenger[30];
            for (int i = 0; i < 30; i++)
            {
                arrival[i]  = new Flight();
                depature[i] = new Flight();
                people[i]   = new Passenger();
            }

            int x = 0;

            foreach (Flight flight in flights)
            {
                arrival[x] = flight;
                x++;
            }
            x = 0;
            foreach (Passenger pers in passengers)
            {
                people[x] = pers;
                x++;
            }
            Menu(ref arrival, ref depature, ref people, ref flight_class_list);
            Console.ReadKey();
        }