Example #1
0
        public async Task Search()
        {
            Aircrafts.Clear();

            List <Aircraft> tempAircrafts = await AircraftService.GetAll();

            foreach (var item in tempAircrafts)
            {
                Aircrafts.Add(item);
            }
        }
Example #2
0
        public void TakeAllRouts()
        {
            Classes.Clear();
            Classes.Add(new FlightsModel {
                clas = "Бизнес"
            });
            Classes.Add(new FlightsModel {
                clas = "Эконом"
            });

            Routs.Clear();
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = @"select id_route,s1.town,s2.town,length_of_route from route   inner join airport s1  on s1.nameAirport = route.id_airport_from 
                 inner join  airport s2 on s2.nameAirport = route.id_airport_to";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader = sqlCommand.ExecuteReader();

            foreach (var i in reader)
            {
                Routs.Add(new RouteModel {
                    IdRoute = reader.GetInt32(0), airport_From_To = $"{reader.GetString(1)} - {reader.GetString(2)}", length_of_route = Convert.ToString(reader.GetInt32(3))
                });
            }
            reader.Close();

            Aircrafts.Clear();
            sqlCommand.CommandText = @"select * from aircrafts";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader2 = sqlCommand.ExecuteReader();

            foreach (var i in reader2)
            {
                Aircrafts.Add(new AircraftModel {
                    name_aircraft = reader2.GetString(0), count_of_seats = reader2.GetInt32(1).ToString(), speed = reader2.GetInt32(2).ToString()
                });
            }
            reader2.Close();

            Company.Clear();
            sqlCommand.CommandText = @"select * from company";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader3 = sqlCommand.ExecuteReader();

            foreach (var i in reader3)
            {
                Company.Add(new CompanyModel {
                    company_name = reader3.GetString(0), cost_of_1km = reader3.GetFloat(1).ToString(), cost_of_business = reader3.GetFloat(2).ToString(), cost_of_econom = reader3.GetFloat(3).ToString()
                });
            }
            reader3.Close();
        }