示例#1
0
        private static Entity PrepareBookingAccommodation(Booking bookinginfo, Accommodation accommodation, Guid bookingId, ITracingService trace)
        {
            trace.Trace("Preparing Booking Accommodation information - Start");
            var accommodationEntity = new Entity(EntityName.BookingAccommodation);

            if (accommodation.AccommodationCode != null)
            {
                accommodationEntity[Attributes.BookingAccommodation.SourceMarketHotelCode] = accommodation.AccommodationCode;
            }
            if (!string.IsNullOrEmpty(accommodation.GroupAccommodationCode))
            {
                accommodationEntity[Attributes.BookingAccommodation.HotelId] = new EntityReference(EntityName.Hotel, new Guid(accommodation.GroupAccommodationCode));
            }
            SetNameFor(accommodation, bookinginfo, accommodationEntity);

            accommodationEntity[Attributes.BookingAccommodation.Order] = accommodation.Order.ToString();
            if (!string.IsNullOrWhiteSpace(accommodation.StartDate))
            {
                accommodationEntity[Attributes.BookingAccommodation.StartDateAndTime] = DateTime.Parse(accommodation.StartDate);
            }
            if (!string.IsNullOrWhiteSpace(accommodation.EndDate))
            {
                accommodationEntity[Attributes.BookingAccommodation.EndDateAndTime] = DateTime.Parse(accommodation.EndDate);
            }
            if (!string.IsNullOrWhiteSpace(accommodation.RoomType))
            {
                accommodationEntity[Attributes.BookingAccommodation.RoomType] = accommodation.RoomType;
            }
            accommodationEntity[Attributes.BookingAccommodation.BoardType]               = CommonXrm.GetBoardType(accommodation.BoardType);
            accommodationEntity[Attributes.BookingAccommodation.HasSharedRoom]           = accommodation.HasSharedRoom;
            accommodationEntity[Attributes.BookingAccommodation.NumberOfParticipants]    = accommodation.NumberOfParticipants;
            accommodationEntity[Attributes.BookingAccommodation.NumberOfRooms]           = accommodation.NumberOfRooms;
            accommodationEntity[Attributes.BookingAccommodation.WithTransfer]            = accommodation.WithTransfer;
            accommodationEntity[Attributes.BookingAccommodation.IsExternalService]       = accommodation.IsExternalService;
            accommodationEntity[Attributes.BookingAccommodation.ExternalServiceCode]     = CommonXrm.GetExternalServiceCode(accommodation.ExternalServiceCode);
            accommodationEntity[Attributes.BookingAccommodation.NotificationRequired]    = accommodation.NotificationRequired;
            accommodationEntity[Attributes.BookingAccommodation.NeedTourGuideAssignment] = accommodation.NeedsTourGuideAssignment;
            accommodationEntity[Attributes.BookingAccommodation.ExternalTransfer]        = accommodation.IsExternalTransfer;
            accommodationEntity[Attributes.BookingAccommodation.TransferServiceLevel]    = CommonXrm.GetTransferServiceLevel(accommodation.TransferServiceLevel);
            if (!string.IsNullOrWhiteSpace(accommodation.AccommodationDescription))
            {
                accommodationEntity[Attributes.BookingAccommodation.SourceMarketHotelName] = accommodation.AccommodationDescription;
            }
            accommodationEntity[Attributes.BookingAccommodation.BookingId]    = new EntityReference(EntityName.Booking, bookingId);
            accommodationEntity[Attributes.BookingAccommodation.Participants] = BookingHelper.PrepareTravelParticipantsInfoForChildRecords(bookinginfo.TravelParticipant, trace, accommodation.TravelParticipantAssignment);
            accommodationEntity[Attributes.Booking.StateCode]  = new OptionSetValue((int)Statecode.Active);
            accommodationEntity[Attributes.Booking.StatusCode] = CommonXrm.GetAccommodationStatus(accommodation.Status);
            accommodationEntity[Attributes.Booking.Remarks]    = RemarksHelper.GetRemarksTextFromPayload(accommodation.Remark);
            trace.Trace("Preparing Booking Transport information - End");

            return(accommodationEntity);
        }
示例#2
0
        private static Entity PrepareBookingTransfer(Booking bookinginfo, Transfer transfer, Guid bookingId, ITracingService trace)
        {
            trace.Trace("Preparing Booking Transfer information - Start");
            var transferEntity = new Entity(EntityName.BookingTransfer);

            if (!string.IsNullOrWhiteSpace(transfer.TransferCode))
            {
                transferEntity[Attributes.BookingTransfer.TransferCode] = transfer.TransferCode;
            }

            SetNameFor(transfer, bookinginfo, transferEntity);

            transferEntity[Attributes.BookingTransfer.Order] = transfer.Order;
            if (!string.IsNullOrWhiteSpace(transfer.StartDate))
            {
                transferEntity[Attributes.BookingTransfer.StartDateAndTime] = DateTime.Parse(transfer.StartDate);
            }
            if (!string.IsNullOrWhiteSpace(transfer.EndDate))
            {
                transferEntity[Attributes.BookingTransfer.EndDateTime] = DateTime.Parse(transfer.EndDate);
            }

            transferEntity[Attributes.BookingTransfer.TransferType] = CommonXrm.GetTransferType(transfer.TransferType);
            transferEntity[Attributes.BookingTransfer.Category]     = transfer.Category;
            if (!string.IsNullOrWhiteSpace(transfer.DepartureAirport))
            {
                transferEntity[Attributes.BookingTransfer.DepartureGatewayId] = new EntityReference(EntityName.Gateway, new Guid(transfer.DepartureAirport));
            }
            if (!string.IsNullOrWhiteSpace(transfer.ArrivalAirport))
            {
                transferEntity[Attributes.BookingTransfer.ArrivalGatewayId] = new EntityReference(EntityName.Gateway, new Guid(transfer.ArrivalAirport));
            }

            transferEntity[Attributes.BookingTransfer.Participants] = BookingHelper.PrepareTravelParticipantsInfoForChildRecords(bookinginfo.TravelParticipant, trace, transfer.TravelParticipantAssignment);

            transferEntity[Attributes.BookingTransfer.BookingId]           = new EntityReference(EntityName.Booking, bookingId);
            transferEntity[Attributes.Booking.Remarks]                     = RemarksHelper.GetRemarksTextFromPayload(transfer.Remark);
            transferEntity[Attributes.BookingTransfer.TransferDescription] = (!string.IsNullOrWhiteSpace(transfer.TransferDescription)) ?
                                                                             transfer.TransferDescription : string.Empty;
            trace.Trace("Preparing Booking Transfer information - End");

            return(transferEntity);
        }
        /// <summary>
        /// To process booking information
        /// </summary>
        /// <returns></returns>
        public void ProcessBookingInfo()
        {
            trace.Trace("Processing Booking - start");
            XrmResponse xrmResponse   = null;
            var         bookingEntity = BookingHelper.GetBookingEntityFromPayload(payloadBooking.BookingInfo, trace);

            xrmResponse             = CommonXrm.UpsertEntity(bookingEntity, crmService);
            payloadBooking.Response = new BookingResponse();

            if (xrmResponse.Create)
            {
                payloadBooking.DeleteBookingRole  = false;
                payloadBooking.DeleteChildRecords = false;
                payloadBooking.Response.Created   = true;
            }
            payloadBooking.BookingId   = xrmResponse.Id;
            payloadBooking.Response.Id = xrmResponse.Id;

            trace.Trace("Processing Booking - end");
        }