/// <summary>Busca vuelo especifico en la DB</summary> /// <param name="id">Id del vuelo a busac</param> /// <returns>Entity con el resultado de la query</returns> public static Entity Find(int id) { try { var table = PgConnection.Instance.ExecuteFunction(FIND_FLIGHT, id); Flight flight = null; if (table.Rows.Count > 0) { flight = new Flight(Convert.ToInt32(table.Rows[0][0])); flight.Id = Convert.ToInt32(table.Rows[0][0]); flight.price = Convert.ToDouble(table.Rows[0][1]); flight.departure = table.Rows[0][2].ToString(); flight.arrival = table.Rows[0][3].ToString(); flight.loc_departure = LocationRepository.GetLocationById(Convert.ToInt32(table.Rows[0][4])); flight.loc_arrival = LocationRepository.GetLocationById(Convert.ToInt32(table.Rows[0][5])); flight.plane = (Airplane)AirplanesRepository.Find(Convert.ToInt32(table.Rows[0][6])); } return(flight); } catch (DatabaseException ex) { Console.WriteLine(ex.ToString()); throw new DbErrorException("¡Ups! Hubo un error con la Base de Datos", ex); } catch (System.Exception) { throw; } finally { } }
static private Flight GetRow(DataTable table, int i) { Flight flight = new Flight(Convert.ToInt32(table.Rows[i][0])); flight.Id = Convert.ToInt32(table.Rows[i][0]); flight.plane = (Airplane)AirplanesRepository.Find(Convert.ToInt32(table.Rows[i][1])); flight.price = Convert.ToDouble(table.Rows[i][2]); flight.departure = table.Rows[i][3].ToString(); flight.arrival = table.Rows[i][4].ToString(); flight.loc_departure = LocationRepository.GetLocationById(Convert.ToInt32(table.Rows[i][5])); flight.loc_arrival = LocationRepository.GetLocationById(Convert.ToInt32(table.Rows[i][6])); return(flight); }