Пример #1
0
        private DetailView BuildPublicSettingsView(ModuleInstanceView parent, DetailView settingsData, IDictionary<string, string> parameters)
        {
            string eventId;

            if (parameters.TryGetValue("EventId", out eventId))
            {
                var request = new ReadEventDetailRequest() { EventId = int.Parse(eventId, CultureInfo.InvariantCulture) };
                var eventDetail = parent.ProcessRequest<ReadEventDetailResponse>(request).Event;

                DynamicColumnData = eventDetail.DynamicColumns;
                DynamicColumnDefitions = CommonUtils.GetDynamicColumnInstances(parent, Constants.EventDynamicColumnEntityId);

                foreach (var zone in settingsData.StaticPageZones.Select(z => z.Value).Union(settingsData.DynamicPageZones))
                {
                    foreach (var column in zone.FieldColumns)
                    {
                        List<Field> occurrencesFieldList = null;
                        foreach (var field in column.Fields)
                        {
                            if (field.FieldName == "Occurrences")
                            {
                                occurrencesFieldList = PopulateOccurrencesFieldData(parent, eventDetail, field, parameters);
                                field.FieldName = "ReplaceMe";
                            }
                            else
                            {
                                PopulateFieldData(parent, eventDetail, field);
                            }
                        }

                        //Replace Locations Complex Field with correct field list
                        if (occurrencesFieldList != null)
                        {
                            var index = column.Fields.IndexOf(column.Fields.First(f => f.FieldName == "ReplaceMe"));
                            column.Fields.InsertRange(index, occurrencesFieldList);
                            index = column.Fields.IndexOf(column.Fields.First(f => f.FieldName == "ReplaceMe"));
                            column.Fields.RemoveAt(index);
                        }
                    }
                }

                // Add SEO data to response
                PopulateSeoData(parent, eventDetail, parameters);
            }
            return settingsData;
        }
Пример #2
0
        private string GetEvent(ConvertServiceRequest request)
        {
            var eventId = 0;
            if (request.Parameters.ContainsKey("externalId"))
            {
                eventId = LookupDataEntityMapId("Event", request.Parameters["externalId"], false);
            }
            else if (request.Parameters.ContainsKey("id"))
            {
                if (!int.TryParse(request.Parameters["id"], out eventId))
                    throw new BusinessException("Event Id must be a valid integer");
            }

            // create the requests
            var eventRequest = new ReadEventDetailRequest { EventId = eventId, IncludeDisabledAndUnpublished = true };
            var occurrencesRequest = new ListAvailableEventOccurrencesRequest { EventId = eventId, IncludExternalIds = true };
            var discountCodeRequest = new ListEventDiscountCodesRequest { EventId = eventId };

            // add the requests to the dispatcher
            var evnt = ProcessRequest<ReadEventDetailResponse>(eventRequest).Event;
            var occurrences = ProcessRequest<ListAvailableEventOccurrencesResponse>(occurrencesRequest).EventOccurrences;
            var discountCodes = ProcessRequest<ListEventDiscountCodesResponse>(discountCodeRequest).DiscountCodes;

            var viewModel = new EventDetailViewModelV2
            {
                Event = new EventV2
                {
                    EventId = evnt.Id,
                    Title = evnt.Title,
                    EventTopics = evnt.EventTopicNames.Select(e => new EventTopicDtoV2 { Name = e.ToString(CultureInfo.InvariantCulture) }).ToList(),
                    EventTypes = evnt.EventTypeNames.Select(e => new EventTypeDtoV2 { Name = e.ToString(CultureInfo.InvariantCulture) }).ToList(),
                    DirectUrl = evnt.DirectUrl,
                    SummaryDescription = evnt.SummaryDescription,
                    EventContent = evnt.EventContent,
                    PublishDate = evnt.PublishDate.HasValue ? evnt.PublishDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    UnpublishDate = evnt.UnpublishDate.HasValue ? evnt.UnpublishDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    ContactName = evnt.ContactName,
                    ContactPhone = evnt.ContactPhone,
                    ContactEmail = evnt.ContactEmail,
                    ContactPhoneExtension = evnt.ContactPhoneExtension,
                    MaximumAttendees = evnt.MaximumAttendees.HasValue ? evnt.MaximumAttendees.Value.ToString(CultureInfo.InvariantCulture) : null,
                    Cost = evnt.Cost.ToString(CultureInfo.InvariantCulture),
                    IsEnabled = evnt.IsEnabled.ToString(CultureInfo.InvariantCulture),
                    ExternalUrl = evnt.ExternalUrl,
                    OrgUnitId = evnt.OrgUnitId.HasValue ? evnt.OrgUnitId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    ImagePath = evnt.ImagePath,
                    PictureId = evnt.PictureId.HasValue ? evnt.PictureId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    InternalOnly = evnt.InternalOnly.ToString(CultureInfo.InvariantCulture),
                    PublicOnly = evnt.PublicOnly.ToString(CultureInfo.InvariantCulture),
                    CostCenter = evnt.CostCenter,
                    PaymentProcessorConfigurationId = evnt.PaymentProcessorConfigurationId.HasValue ? evnt.PaymentProcessorConfigurationId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    IsNotificationListEnabled = evnt.IsNotificationListEnabled.ToString(CultureInfo.InvariantCulture),
                    IsNotifyContactEnabled = evnt.IsNotifyContactEnabled.ToString(CultureInfo.InvariantCulture),
                    NotificationFrequency = evnt.NotificationFrequency,
                    EventExternalId = evnt.EventExternalId,
                    Keywords = evnt.Keywords,
                    CustomKeywords = evnt.CustomKeywords,
                    IsRegistrationEnabled = evnt.IsRegistrationEnabled.ToString(CultureInfo.InvariantCulture),
                    SpecialInstructions = evnt.SpecialInstructions,
                    Custom1 = evnt.Custom1,
                    Custom2 = evnt.Custom2,
                    Custom3 = evnt.Custom3,
                    DynamicColumns = evnt.DynamicColumns,
                    AllowPayOnSite = evnt.AllowPayOnSite.ToString(CultureInfo.InvariantCulture),

                    DiscountCodes = discountCodes.Select(d => new DiscountCodeDtoV2
                    {
                        Code = d.Code,
                        Description = d.Description,
                        DiscountType = d.DiscountTypeName,
                        DiscountValue = d.DiscountValue.ToString(CultureInfo.InvariantCulture),
                        IsEnabled = d.IsEnabled.ToString(CultureInfo.InvariantCulture),
                        IsGroupCode = d.IsGroupCode.ToString(CultureInfo.InvariantCulture),
                        IsFromOrgUnit = d.IsFromOrgUnit.ToString(CultureInfo.InvariantCulture),
                        RequiredGroupSize = d.RequiredGroupSize.HasValue ? d.RequiredGroupSize.Value.ToString(CultureInfo.InvariantCulture) : null,
                        StartDate = d.StartDate.HasValue ? d.StartDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                        EndDate = d.EndDate.HasValue ? d.EndDate.Value.ToString(CultureInfo.InvariantCulture) : null
                    }).ToList()
                },

                Occurrences = occurrences.Select(o => new EventOccurrenceV2
                {
                    OccurrenceId = o.Id.ToString(CultureInfo.InvariantCulture),
                    EventId = evnt.Id.ToString(CultureInfo.InvariantCulture),
                    EventExternalId = evnt.EventExternalId,
                    IsEnabled = o.IsEnabled.ToString(CultureInfo.InvariantCulture),
                    OrgUnitId = o.OrgUnitId.HasValue ? o.OrgUnitId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    OrgUnitExternalId = o.OrgUnitExternalId,
                    LocationOrgUnitId = o.LocationOrgUnitId.HasValue ? o.LocationOrgUnitId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    LocationOrgUnitExternalId = o.LocationOrgUnitExternalId,
                    LocationName = o.LocationName,
                    Address1 = o.Address1,
                    Address2 = o.Address2,
                    City = o.City,
                    State = o.StateName,
                    PostalCode = o.PostalCode,
                    Country = o.CountryName,
                    Latitude = o.Latitude.HasValue ? o.Latitude.Value.ToString(CultureInfo.InvariantCulture) : null,
                    Longitude = o.Longitude.HasValue ? o.Longitude.Value.ToString(CultureInfo.InvariantCulture) : null,
                    ContactName = o.EffectiveContactName,
                    ContactPhone = o.EffectiveContactPhone,
                    ContactPhoneExtension = o.EffectiveContactPhoneExtension,
                    ContactEmail = o.EffectiveContactEmail,
                    MaximumAttendees = o.EffectiveMaximumAttendees.HasValue ? o.EffectiveMaximumAttendees.Value.ToString(CultureInfo.InvariantCulture) : null,
                    Presenter = o.Presenter,
                    Cost = o.EffectiveCost.ToString(CultureInfo.InvariantCulture),
                    CostCenter = o.CostCenter,
                    RegistrationStartDate = o.RegistrationStartDate.HasValue ? o.RegistrationStartDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    RegistrationEndDate = o.RegistrationEndDate.HasValue ? o.RegistrationEndDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    IsPriceScheduleEnabled = o.IsPriceScheduleEnabled.ToString(CultureInfo.InvariantCulture),
                    EarlyCost = o.EarlyCost.HasValue ? o.EarlyCost.Value.ToString(CultureInfo.InvariantCulture) : null,
                    EarlyCostEndDate = o.EarlyCostEndDate.HasValue ? o.EarlyCostEndDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    EarlyCostEndDays = o.EarlyCostEndDays.HasValue ? o.EarlyCostEndDays.Value.ToString(CultureInfo.InvariantCulture) : null,
                    LateCost = o.LateCost.HasValue ? o.LateCost.Value.ToString(CultureInfo.InvariantCulture) : null,
                    LateCostStartDate = o.LateCostStartDate.HasValue ? o.LateCostStartDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                    LateCostStartDays = o.LateCostStartDays.HasValue ? o.LateCostStartDays.Value.ToString(CultureInfo.InvariantCulture) : null,
                    PaymentProcessorConfigurationId = o.PaymentProcessorConfigurationId.HasValue ? o.PaymentProcessorConfigurationId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    DynamicFormsId = o.DynamicFormsId.HasValue ? o.DynamicFormsId.Value.ToString(CultureInfo.InvariantCulture) : null,
                    OccurrenceExternalId = o.EventOccurrenceExternalId,
                    IsRegistrationEnabled = o.IsRegistrationEnabled.ToString(CultureInfo.InvariantCulture),
                    IsNotificationListEnabled = o.IsNotificationListEnabled.ToString(CultureInfo.InvariantCulture),
                    IsNotifyContactEnabled = o.IsNotifyContactEnabled.ToString(CultureInfo.InvariantCulture),
                    SpecialInstructions = o.SpecialInstructions,
                    AllowPayOnSite = o.AllowPayOnSite.ToString(CultureInfo.InvariantCulture),
                    EventOccurrenceDates = o.Dates.Select(d => new EventOccurrenceDateV2
                    {
                        StartDate = d.StartDate.HasValue ? d.StartDate.Value.ToString(CultureInfo.InvariantCulture) : null,
                        EndDate = d.EndDate.HasValue ? d.EndDate.Value.ToString(CultureInfo.InvariantCulture) : null
                    }).ToList()
                }).ToArray()
            };

            return CommonUtils.XmlSerialize(viewModel);
        }