private static Entity PrepareBookingTransport(Booking bookinginfo, Transport transport, Guid bookingId, ITracingService trace) { trace.Trace("Transport populate fields - start"); var transportEntity = new Entity(EntityName.BookingTransport); SetNameFor(transport, bookinginfo, transportEntity); if (!string.IsNullOrWhiteSpace(transport.TransportCode)) { transportEntity[Attributes.BookingTransport.TransportCode] = transport.TransportCode; } if (!string.IsNullOrWhiteSpace(transport.TransportDescription)) { transportEntity[Attributes.BookingTransport.Description] = transport.TransportDescription; } transportEntity[Attributes.BookingTransport.Order] = transport.Order; if (!string.IsNullOrWhiteSpace(transport.StartDate)) { transportEntity[Attributes.BookingTransport.StartDateAndTime] = DateTime.Parse(transport.StartDate); } if (!string.IsNullOrWhiteSpace(transport.EndDate)) { transportEntity[Attributes.BookingTransport.EndDateAndTime] = DateTime.Parse(transport.EndDate); } transportEntity[Attributes.BookingTransport.TransferType] = CommonXrm.GetTransferType(transport.TransferType); if (!string.IsNullOrWhiteSpace(transport.DepartureAirport)) { transportEntity[Attributes.BookingTransport.DepartureGatewayId] = new EntityReference(EntityName.Gateway, new Guid(transport.DepartureAirport)); } if (!string.IsNullOrWhiteSpace(transport.ArrivalAirport)) { transportEntity[Attributes.BookingTransport.ArrivalGatewayId] = new EntityReference(EntityName.Gateway, new Guid(transport.ArrivalAirport)); } if (!string.IsNullOrWhiteSpace(transport.CarrierCode)) { transportEntity[Attributes.BookingTransport.CarrierCode] = transport.CarrierCode; } if (!string.IsNullOrWhiteSpace(transport.FlightNumber)) { transportEntity[Attributes.BookingTransport.FlightNumber] = transport.FlightNumber; } if (!string.IsNullOrWhiteSpace(transport.FlightIdentifier)) { transportEntity[Attributes.BookingTransport.FlightIdentifier] = transport.FlightIdentifier; } transportEntity[Attributes.BookingTransport.NumberOfParticipants] = transport.NumberOfParticipants; transportEntity[Attributes.BookingTransport.BookingId] = new EntityReference(EntityName.Booking, bookingId); transportEntity[Attributes.BookingTransport.Participants] = BookingHelper.PrepareTravelParticipantsInfoForChildRecords(bookinginfo.TravelParticipant, trace, transport.TravelParticipantAssignment); transportEntity[Attributes.Booking.Remarks] = RemarksHelper.GetRemarksTextFromPayload(transport.Remark); transportEntity[Attributes.BookingTransport.TransportType] = CommonXrm.GetTransportType(transport.TransportType); trace.Trace("Transport populate fields - end"); return(transportEntity); }