public static void PopulateGeneralFields(Entity booking, BookingGeneral general, ITracingService trace)
 {
     if (trace == null)
     {
         throw new InvalidPluginExecutionException("Tracing service is null;");
     }
     trace.Trace("Booking general - start");
     if (booking == null)
     {
         throw new InvalidPluginExecutionException("Booking entity is null.");
     }
     if (general == null)
     {
         throw new InvalidPluginExecutionException("Booking general information is null.");
     }
     if (general != null)
     {
         trace.Trace("Booking populate general - start");
         booking[Attributes.Booking.BookingDate]          = (!string.IsNullOrWhiteSpace(general.BookingDate)) ? Convert.ToDateTime(general.BookingDate) : (DateTime?)null;
         booking[Attributes.Booking.DepartureDate]        = (!string.IsNullOrWhiteSpace(general.DepartureDate)) ? Convert.ToDateTime(general.DepartureDate) : (DateTime?)null;
         booking[Attributes.Booking.ReturnDate]           = (!string.IsNullOrWhiteSpace(general.ReturnDate)) ? Convert.ToDateTime(general.ReturnDate) : (DateTime?)null;
         booking[Attributes.Booking.DestinationGatewayId] = (!string.IsNullOrWhiteSpace(general.Destination)) ? new EntityReference(EntityName.Gateway, new Guid(general.Destination)) : null;
         booking[Attributes.Booking.TourOperatorId]       = (!string.IsNullOrWhiteSpace(general.ToCode)) ? new EntityReference(EntityName.TourOperator, new Guid(general.ToCode)) : null;
         booking[Attributes.Booking.BrandId]              = (!string.IsNullOrWhiteSpace(general.Brand)) ? new EntityReference(EntityName.Brand, new Guid(general.Brand)) : null;
         booking[Attributes.Booking.BrochureCode]         = (!string.IsNullOrWhiteSpace(general.BrochureCode)) ? general.BrochureCode : string.Empty;
         booking[Attributes.Booking.IsLateBooking]        = general.IsLateBooking;
         booking[Attributes.Booking.NumberOfParticipants] = general.NumberOfParticipants;
         booking[Attributes.Booking.NumberOfAdults]       = general.NumberOfAdults;
         booking[Attributes.Booking.NumberOfChildren]     = general.NumberOfChildren;
         booking[Attributes.Booking.NumberOfInfants]      = general.NumberOfInfants;
         booking[Attributes.Booking.TravelAmount]         = new Money(general.TravelAmount);
         if (!string.IsNullOrWhiteSpace(general.Currency))
         {
             booking[Attributes.Booking.TransactionCurrencyId] = new EntityReference(EntityName.Currency, new Guid(general.Currency));
         }
         booking[Attributes.Booking.HasSourceMarketComplaint]    = general.HasComplaint;
         booking[Attributes.Booking.NumberOfDealsOnConsultation] = general.NumberOfDealsOnConsultation;
         booking[Attributes.Booking.AmountDueDate] = (!string.IsNullOrWhiteSpace(general.AmountDueDate)) ?
                                                     Convert.ToDateTime(general.AmountDueDate) : (DateTime?)null;
         booking[Attributes.Booking.ProductTypeCode]            = CommonXrm.GetProductTypeCode(general.ProductTypeCode);
         booking[Attributes.Booking.ProductTypeCodeDescription] = (!string.IsNullOrWhiteSpace(general.ProductTypeCodeDescription)) ?
                                                                  general.ProductTypeCodeDescription : null;
         booking[Attributes.Booking.OperatorCode] = (!string.IsNullOrWhiteSpace(general.OperatorCode)) ?
                                                    general.OperatorCode : string.Empty;
         booking[Attributes.Booking.OperatorCodeDescription] = (!string.IsNullOrWhiteSpace(general.OperatorCodeDescription)) ?
                                                               general.OperatorCodeDescription : string.Empty;
         booking[Attributes.Booking.TotalDueAmount]         = new Money(general.TotalDueAmount);
         booking[Attributes.Booking.TotalPaid]              = new Money(general.TotalPaid);
         booking[Attributes.Booking.DepositAmount]          = new Money(general.DepositAmount);
         booking[Attributes.Booking.IsLowDeposit]           = general.IsLowDeposit;
         booking[Attributes.Booking.DepositDueDate]         = Convert.ToDateTime(general.DepositDueDate);
         booking[Attributes.Booking.CancellationDate]       = Convert.ToDateTime(general.CancellationDate);
         booking[Attributes.Booking.NumberOfSeniorCitizens] = general.NumberOfSeniorCitizens;
         trace.Trace("Booking populate general - end");
     }
     trace.Trace("Booking general - end");
 }
Example #2
0
 public void ResolveGeneralReferences(BookingGeneral general)
 {
     if (general == null)
     {
         return;
     }
     general.Brand       = brandBucket.GetBy(general.Brand);
     general.Destination = gatewayBucket.GetBy(general.Destination);
     general.ToCode      = tourOperatorBucket.GetBy(general.ToCode);
 }