// use ordinals to speed up access to DataReader
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497
 // parameters:
 //  reader: IDataReader from SQLClient
 public void Populate(IDataReader reader, PassengersOnFlightCheckedInDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.RecordLocator))
     {
         RecordLocator = reader.GetString(ordinals.RecordLocator);
     }
     if (!reader.IsDBNull(ordinals.ReceivedFrom))
     {
         ReceivedFrom = reader.GetString(ordinals.ReceivedFrom);
     }
     if (!reader.IsDBNull(ordinals.PassengerName))
     {
         PassengerName = reader.GetString(ordinals.PassengerName);
     }
     if (!reader.IsDBNull(ordinals.PassengerTypeName))
     {
         PassengerTypeName = reader.GetString(ordinals.PassengerTypeName);
     }
     if (!reader.IsDBNull(ordinals.PassengerId))
     {
         PassengerId = reader.GetGuid(ordinals.PassengerId);
     }
     if (!reader.IsDBNull(ordinals.BookingId))
     {
         BookingId = reader.GetGuid(ordinals.BookingId);
     }
     if (!reader.IsDBNull(ordinals.BookingPassengerId))
     {
         BookingPassengerId = reader.GetGuid(ordinals.BookingPassengerId);
     }
     if (!reader.IsDBNull(ordinals.BookingFlightSegmentId))
     {
         BookingFlightSegmentId = reader.GetGuid(ordinals.BookingFlightSegmentId);
     }
 }
Пример #2
0
        /// <summary>Get all passengers on a flight</summary>
        /// <cardinality>Many</cardinality>
        public List <PassengersOnFlightCheckedInData> PassengersOnFlightCheckedIn(
            Guid flightId
            )
        {
            var ret = new List <PassengersOnFlightCheckedInData>();

            string sql = @" 
                    select
						(	
							select top 1 booking_identifier_value
							from booking_identifier as bi
							where bi.booking_id = bp.booking_id
							  and bi.booking_identifier_type_rcd = dbo.ref('booking_identifier_type_ref.RL')
							order by bi.date_time desc
						) as record_locator
						,b.received_from
	                    ,pa.passenger_name
	                    ,ptr.passenger_type_name
                        ,pa.passenger_id
                        ,bp.booking_id
                        ,bp.booking_passenger_id
                        ,bfs.booking_flight_segment_id
                    from passenger						as pa 
                    inner join passenger_type_ref		as ptr	on ptr.passenger_type_rcd = pa.passenger_type_rcd
                    inner join booking_passenger		as bp	on	bp.passenger_id = pa.passenger_id
																and bp.became_booking_passenger_id is null
					inner join booking_flight_segment	as bfs	on bfs.booking_id = bp.booking_id
					inner join booking					as b	on b.booking_id = bp.booking_id
					inner join flight_segment			as fs	on fs.flight_segment_id = bfs.flight_segment_id

                    --realwhere

                    where fs.flight_id = @flight_id
					  and pa.became_passenger_id is null
					  and pa.default_state_rcd in (dbo.ref('default_state_ref.C'), dbo.ref('default_state_ref.U'))
					  and dbo.BookingPassengerEventOneIsLast(
								bp.booking_passenger_id, 
								dbo.ref('booking_passenger_event_type_ref.CIFS'), 
								dbo.ref('booking_passenger_event_type_ref.COFS')
								) <> 0

					order by record_locator
                ";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();
                conn.BeginTransaction(IsolationLevel.ReadUncommitted).Commit();

                using (var command = new SqlCommand(sql, conn)) {
                    command.Parameters.Add("@flight_id", SqlDbType.UniqueIdentifier).Value = flightId;

                    Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.PassengerSearch.PassengersOnFlightCheckedIn");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new PassengersOnFlightCheckedInDataOrdinals(reader);

                    while (reader.Read())
                    {
                        var data = new PassengersOnFlightCheckedInData();
                        data.Populate(reader, ordinals);
                        ret.Add(data);
                    }

                    reader.Close();
                }

                return(ret);
            }
        }