public void ListAvailableEventOccurrences()
        {
            //setup
            var handler = CreateHandler();
            var request = new ListAvailableEventOccurrencesRequest { EventId = 1, IncludExternalIds = true };

            //act
            var response = HandleRequest<ListAvailableEventOccurrencesResponse>(handler, request);

            //assert
            Assert.IsNotNull(response);
        }
Пример #2
0
        private List<Field> PopulateOccurrencesFieldData(ModuleInstanceView parent, EventDetailDto eventDetail, Field templateField, IDictionary<string, string> parameters)
        {
            var locationsFields = new List<Field>();
            var request = new ListAvailableEventOccurrencesRequest() { EventId = int.Parse(eventDetail.Id) };
            var response = parent.ProcessRequest<ListAvailableEventOccurrencesResponse>(request);
            var seoHelper = new SeoHelper(parent, parameters);

            foreach (var occurrence in response.EventOccurrences)
            {
                var occurrenceField = (Field)templateField.Clone();

                if (string.IsNullOrEmpty(_viewSettings.SeoSchema))
                    _viewSettings.SeoSchema = seoHelper.BuildSeoSchemaField(occurrence);

                foreach (var column in occurrenceField.FieldColumns)
                {
                    foreach (var field in column.Fields)
                    {
                        switch (field.FieldName)
                        {
                            case "LocationName":
                                field.Value = occurrence.EffectiveLocationName;
                                break;
                            case "LocationAddress":
                                field.Value = occurrence.EffectiveCompleteAddress;
                                break;
                            case "Presenter":
                                field.Value = occurrence.Presenter;
                                break;
                            case "ContactName":
                                field.Value = occurrence.EffectiveContactName;
                                break;
                            case "ContactPhone":
                                var sb = new StringBuilder();
                                sb.Append(occurrence.EffectiveContactPhone);
                                if (!string.IsNullOrEmpty(occurrence.EffectiveContactPhoneExtension))
                                    sb.Append(" ext. " + occurrence.EffectiveContactPhoneExtension);
                                field.Value = sb.ToString();
                                break;
                            case "ContactEmail":
                                field.Value = occurrence.EffectiveContactEmail;
                                break;
                            case "MaxAttendees":
                                field.Value = occurrence.EffectiveMaximumAttendees;
                                break;
                            case "Cost":
                                field.Value = string.Format("{0:C}", occurrence.EffectiveCost);
                                break;
                            case "AvailableSeats":
                                field.Value = occurrence.Availability;
                                break;
                            case "SpecialInstructions":
                                field.Value = occurrence.SpecialInstructions;
                                break;
                            case "Map":
                                field.Value = "mapDiv_" + occurrence.Id;
                                field.MappingProvider = _mappingSettings.MappingProvider.ToString().ToUpperInvariant();
                                field.MapItem = new MapItem()
                                {
                                    Title = occurrence.EventTitle,
                                    Latitude = occurrence.Latitude.HasValue ? occurrence.Latitude.ToString() : string.Empty,
                                    Longitude = occurrence.Longitude.HasValue ? occurrence.Longitude.ToString() : string.Empty,
                                    LocationAddress = occurrence.EffectiveCompleteAddress,
                                    LocationPhoneNum = occurrence.EffectiveContactPhone
                                };
                                break;
                            case "RegisterButton":
                                if (occurrence.IsRegistrationEnabled)
                                    field.Value = "<input type='button' class='btn btn-primary' value='Register' data-ng-click='Register(" + occurrence.Id + ")' />";
                                else
                                    field.Value = null;
                                break;
                            case "AddToCartButton":
                                if (occurrence.IsRegistrationEnabled)
                                    field.Value = "<input type='button' class='btn btn-primary' value='Add To Cart' data-ng-click='AddToCart(" + occurrence.Id + ")' />";
                                else
                                    field.Value = null;
                                break;
                            case "DateAndTime":
                                var dtBuilder = new StringBuilder();
                                var formatStr = "{0} - {1} until {2}";
                                foreach(var d in occurrence.Dates)
                                {
                                    if (d.StartDate.HasValue && d.EndDate.HasValue)
                                    {
                                        if (dtBuilder.Length > 0)
                                            dtBuilder.Append("<br/>");

                                        var dateStr = d.StartDate.Value.ToString("MMM. d, yyyy");
                                        var startTime = d.StartDate.Value.ToShortTimeString();
                                        var endTime = d.EndDate.Value.ToShortTimeString();
                                        dtBuilder.AppendFormat(formatStr, dateStr, startTime, endTime);
                                    }
                                }
                                field.Value = dtBuilder.ToString();
                                break;
                        }
                    }
                }

                locationsFields.Add(occurrenceField);
            }

            return locationsFields;
        }
Пример #3
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);
        }