private void Buy_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ServiceReference1.FlightAirportDto flight = (ServiceReference1.FlightAirportDto)dgFlightsAirportsBuyTicket.SelectedItem;
                ServiceReference1.PassengerDto     pass   = (ServiceReference1.PassengerDto)dgPassengersBuyTicket.SelectedItem;

                ServiceReference1.TicketDto        ticket  = new ServiceReference1.TicketDto();
                ServiceReference1.TicketDto[]      tickets = proxyTicket.GetTickets();
                List <ServiceReference1.TicketDto> ticks   = new List <ServiceReference1.TicketDto>(tickets);
                int max = ticks.Max(x => x.TicketId);
                ticket.TicketId    = max + 1;
                ticket.Price       = 100;
                ticket.FlightId    = flight.FlightId;
                ticket.PassengerId = pass.PassengerId;
                proxyTicket.AddTicket(ticket);

                var passengers = proxyPassenger.GetPassengers();
                var flights    = proxyFlight.GetFlights();
                tickets = proxyTicket.GetTickets();
                var flightsAirports = proxyFlight.GetFlightsAirports();

                dgPassengers.ItemsSource               = passengers;
                dgPassengersBuyTicket.ItemsSource      = passengers;
                dgFlights.ItemsSource                  = flights;
                dgTickets.ItemsSource                  = tickets;
                dgFlightsAirports.ItemsSource          = flightsAirports;
                dgFlightsAirportsBuyTicket.ItemsSource = flightsAirports;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Add proper params", "PARAMS !!", MessageBoxButton.OK);
                return;
            }
        }
 private void OverViewPassengersRefresh(System.Windows.Controls.DataGrid dg)
 {
     ServiceReference1.PlaneDto       plane = (ServiceReference1.PlaneDto)dg.SelectedItem;
     ServiceReference1.PassengerDto[] passengers;
     if (plane == null)
     {
         passengers = new ServiceReference1.PassengerDto[0];
     }
     else
     {
         passengers = proxyPassenger.GetPassengersWherePlaneId(plane.PlaneId);
     }
     dgOverViewPassengers.ItemsSource = passengers;
 }
        public void MyInit()
        {
            ServiceReference1.AirportDto airport = new ServiceReference1.AirportDto();
            airport.AirportId = 1;
            airport.City      = "Danzig";
            proxyAirports.AddAirport(airport);
            airport.AirportId = 2;
            airport.City      = "Moscow";
            proxyAirports.AddAirport(airport);
            airport.AirportId = 3;
            airport.City      = "Breslau";
            proxyAirports.AddAirport(airport);

            ServiceReference1.PlaneDto plane = new ServiceReference1.PlaneDto();
            plane.PlaneId      = 1;
            plane.SerialNumber = 12311;
            plane.AirportId    = 1;
            proxyPlane.AddPlane(plane);
            plane              = new ServiceReference1.PlaneDto();
            plane.PlaneId      = 2;
            plane.SerialNumber = 123111;
            plane.AirportId    = 2;
            proxyPlane.AddPlane(plane);

            ServiceReference1.PassengerDto pass = new ServiceReference1.PassengerDto();
            pass.PassengerId = 1;
            pass.FirstName   = "Adam";
            pass.LastName    = "Smith";
            pass.PlaneId     = null;
            proxyPassenger.AddPassenger(pass);
            pass             = new ServiceReference1.PassengerDto();
            pass.PassengerId = 2;
            pass.FirstName   = "John";
            pass.LastName    = "Wayne";
            pass.PlaneId     = null;
            proxyPassenger.AddPassenger(pass);

            ServiceReference1.FlightDto flight = new ServiceReference1.FlightDto();
            flight.FlightId       = 1;
            flight.TimeDeparture  = new System.DateTime(2019, 11, 2, 13, 13, 13);
            flight.TimeArrival    = new System.DateTime(2019, 11, 3, 16, 16, 16);
            flight.AimArrivalId   = 2;
            flight.AimDepartureId = 1;
            flight.PlaneId        = 1;
            proxyFlight.AddFlight(flight);
            flight.FlightId       = 2;
            flight.TimeDeparture  = new System.DateTime(2019, 11, 5, 13, 13, 13);
            flight.TimeArrival    = new System.DateTime(2019, 11, 8, 16, 16, 16);
            flight.AimArrivalId   = 3;
            flight.AimDepartureId = 2;
            flight.PlaneId        = 2;
            proxyFlight.AddFlight(flight);
            flight.FlightId       = 3;
            flight.TimeDeparture  = new System.DateTime(2019, 11, 7, 13, 13, 13);
            flight.TimeArrival    = new System.DateTime(2019, 11, 16, 16, 16, 16);
            flight.AimArrivalId   = 3;
            flight.AimDepartureId = 2;
            flight.PlaneId        = 1;
            proxyFlight.AddFlight(flight);

            ServiceReference1.TicketDto ticket = new ServiceReference1.TicketDto();
            ticket.TicketId    = 1;
            ticket.Price       = 100;
            ticket.FlightId    = 1;
            ticket.PassengerId = 1;
            proxyTicket.AddTicket(ticket);
            ticket.TicketId    = 2;
            ticket.Price       = 100;
            ticket.FlightId    = 2;
            ticket.PassengerId = 1;
            proxyTicket.AddTicket(ticket);
        }
 private void DgPassengersBuyTicket_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     ServiceReference1.PassengerDto passenger = (ServiceReference1.PassengerDto)dgPassengersBuyTicket.SelectedItem;
     BuyTicketFirstName.Content = passenger.FirstName;
     BuyTicketLastName.Content  = passenger.LastName;
 }