示例#1
0
        private static void MapOccurrenceDates(EventSearchResultPortalDto result, EventOccurrence occurrence)
        {
            var occurrenceDate = occurrence.EventOccurrenceDates.OrderBy(o => o.StartDate).First();

            result.StartDateFormatted = occurrenceDate.StartDate.ToLongDateString();
            result.OccurenceMonthYear = string.Concat(occurrenceDate.StartDate.ToString("MMMM", CultureInfo.CurrentCulture), " ", occurrenceDate.StartDate.ToString("yyyy", CultureInfo.CurrentCulture));
            result.StartTimeFormatted = occurrenceDate.StartDate.ToShortTimeString();
            result.EndDateFormatted = occurrenceDate.EndDate.HasValue ? occurrenceDate.EndDate.Value.ToShortTimeString() : string.Empty;
            int occurrenceCount = occurrence.EventOccurrenceDates.Count();
            if (occurrenceCount > 1)
            {
                result.StartDateFormatted = occurrenceDate.StartDate.ToString("MMMM dd, yyyy", CultureInfo.CurrentCulture);

                occurrenceDate = occurrence.EventOccurrenceDates.OrderBy(e => e.EndDate).Last();
                if (occurrenceDate.EndDate.HasValue)
                {
                    result.EndDateFormatted = occurrenceDate.EndDate.Value.ToString("MMMM dd, yyyy", CultureInfo.CurrentCulture) + " (" + occurrenceCount.ToString(CultureInfo.CurrentCulture) + ")";
                }
            }
        }
        private void PopulateFieldData(EventSearchResultPortalDto eventResult, Field field)
        {
            //Handle Dynamic Column Data
            if (field.FieldName.StartsWith(Constants.DynamicColumnPrefix))
            {
                var dynamicColumnFieldName = field.FieldName.Replace(Constants.DynamicColumnPrefix, string.Empty);
                var dynamicColumn = _dynamicColumnData.FirstOrDefault(c => c.FieldName == dynamicColumnFieldName);
                if (dynamicColumn != null && _dynamicColumnDefinitions.Any(c => c.Name == dynamicColumnFieldName))
                    field.Value = dynamicColumn.FieldValue;
                else
                    field.Value = string.Empty;
            }
            //Handle Standard Column Data
            else
            {
                switch (field.FieldName)
                {
                    case "EventTitleLink":
                        field.Value = eventResult.Title;
                        field.URL = _view.CalculateEventUrl(eventResult.DirectUrl, eventResult.Id, _baseDetailPageUrl);
                        break;
                    case "EventDescription":
                        field.Value = eventResult.SummaryDescription;
                        break;
                    case "SpecialInstructions":
                        field.Value = eventResult.SpecialInstructions;
                        break;
                    case "EventImage":
                        if (!string.IsNullOrEmpty(eventResult.ImagePath))
                            field.URL = eventResult.ImagePath;
                        else
                            field.URL = _view.DefaultEventImageUrl;

                        field.Value = eventResult.Title;
                        break;
                    case "EventTopics":
                        field.Values = eventResult.EventTopics.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(i => i).Cast<object>().ToList();
                        break;
                    case "EventTypes":
                        field.Values = eventResult.EventTypes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(i => i).Cast<object>().ToList();
                        break;
                    case "Custom1":
                        field.Value = eventResult.Custom1;
                        break;
                    case "Custom2":
                        field.Value = eventResult.Custom2;
                        break;
                    case "Custom3":
                        field.Value = eventResult.Custom3;
                        break;
                    case "Cost":
                        if (eventResult.HasMultipleOccurrences)
                        {
                            if (eventResult.EffectiveCostMin != eventResult.EffectiveCostMax)
                                field.Value = string.Format("{0:C}", eventResult.EffectiveCostMin) + " - " + string.Format("{0:C}", eventResult.EffectiveCostMax);
                            else
                                field.Value = string.Format("{0:C}", eventResult.EffectiveCostMin);
                        }
                        else
                        {
                            field.Value = string.Format("{0:C}", eventResult.EffectiveCost);
                        }
                        break;
                    case "MaxAttendees":
                        field.Value = eventResult.MaximumAttendees;
                        break;
                    case "Address":
                        field.Value = eventResult.MostProximateLocationCompleteAddress;
                        break;
                    case "Distance":
                        if (eventResult.MostProximateLocationDistance.HasValue)
                            field.Value = Decimal.Round((Decimal)eventResult.MostProximateLocationDistance.Value, 2) + " Miles";
                        else
                            field.Value = null;
                        break;
                    case "LocationName":
                        if (eventResult.HasMultipleOccurrences)
                            field.Value = null;
                        else
                            field.Value = eventResult.EffectiveLocationName;
                        break;
                    case "LocationAddress":
                        if (eventResult.HasMultipleOccurrences)
                            field.Value = null;
                        else
                        {
                            if (string.IsNullOrEmpty(eventResult.EffectiveAddress2))
                                field.Value = string.Format("{0}, {1}, {2} {3}", eventResult.EffectiveAddress1, eventResult.EffectiveCity, eventResult.EffectiveState, eventResult.EffectivePostalCode);
                            else
                                field.Value = string.Format("{0}, {1}, {2}, {3} {4}", eventResult.EffectiveAddress1, eventResult.EffectiveAddress2, eventResult.EffectiveCity, eventResult.EffectiveState, eventResult.EffectivePostalCode);
                        }
                        break;
                    case "SingleOccurrenceDate":
                        if (eventResult.HasMultipleOccurrences)
                            field.Value = null;
                        else
                            field.Value = eventResult.StartDateFormatted;
                        break;
                    case "SingleOccurrenceTime":
                        if (eventResult.HasMultipleOccurrences)
                            field.Value = null;
                        else
                            field.Value = eventResult.StartTimeFormatted;
                        break;
                    case "RegisterButton":
                        if (AllowRegisterButton(eventResult))
                            field.Value = "<input type='button' class='btn btn-primary' value='Register' data-ng-click='Register(" + eventResult.SingleOccurrenceId + ")' />";
                        else
                            field.Value = null;
                        break;
                    case "AddToCartButton":
                        if (AllowRegisterButton(eventResult))
                            field.Value = "<input type='button' class='btn btn-primary' value='Add To Cart' data-ng-click='AddToCart(" + eventResult.SingleOccurrenceId + ")' />";
                        else
                            field.Value = null;
                        break;
                    case "MultipleOccurrenceMessage":
                        if (!eventResult.HasMultipleOccurrences)
                            field.Value = string.Empty;
                        break;
                }
            }
        }
 /// <summary>
 /// Simplifies a long condition, returns true when the Register/Add to Cart buttons are to be rendered.
 /// </summary>
 /// <param name="eventResult"></param>
 /// <returns></returns>
 private bool AllowRegisterButton(EventSearchResultPortalDto eventResult)
 {
     return eventResult.IsRegistrationEnabled && eventResult.HasActiveOccurrence && !eventResult.HasMultipleOccurrences;
 }
示例#4
0
        private void MapEventOccurence(EventSearchResultPortalDto result)
        {
            if (_event.EventOccurrences.Count(_getActive) > 1)
            {
                result.HasMultipleOccurrences = true;
                result.OccurenceMonthYear = string.Empty;

                var minCost = _event.EventOccurrences.Min(o => o.Cost);
                var maxCost = _event.EventOccurrences.Max(o => o.Cost);

                if (minCost != maxCost)
                {
                    result.EffectiveCostMax = maxCost;
                    result.EffectiveCostMin = minCost;
                }
                else
                {
                    result.EffectiveCost = minCost;
                }
            }
            else
            {
                result.HasMultipleOccurrences = false;

                var occurrence = _event.EventOccurrences.First(_getActive);

                result.SingleOccurrenceId = occurrence.Id;
                result.EffectiveCost = occurrence.EffectiveCost;
                result.MaximumAttendees = occurrence.MaximumAttendees;
                MapOccurrenceLocation(result, occurrence);
                MapOccurrenceDates(result, occurrence);
                result.Availability = CalculateAvailableSeats(occurrence);
                result.IsCanceled = occurrence.IsCanceled;
                result.CancellationMessage = occurrence.CancellationMessage;
            }
        }
示例#5
0
 private void MapEvent(EventSearchResultPortalDto result)
 {
     result.ExternalUrl = _event.ExternalUrl;
     result.ImagePath = _event.ImagePath;
     result.AllowEventCart = true;
     result.IsCanceled = _event.IsEffectivelyCanceled;
     result.CancellationMessage = _event.EffectiveCancellationMessage;
     result.Keywords = _event.Keywords;
     result.CustomKeywords = _event.CustomKeywords;
     result.Custom1 = _event.Custom1;
     result.Custom2 = _event.Custom2;
     result.Custom3 = _event.Custom3;
     result.SpecialInstructions = _event.SpecialInstructions;
 }
示例#6
0
 private static void MapOccurrenceLocation(EventSearchResultPortalDto result, EventOccurrence occurrence)
 {
     result.EffectiveLocationName = occurrence.EffectiveLocationName;
     result.EffectiveAddress1 = occurrence.EffectiveAddress1;
     result.EffectiveAddress2 = occurrence.EffectiveAddress2;
     result.EffectiveCity = occurrence.EffectiveCity;
     result.EffectivePostalCode = occurrence.EffectivePostalCode;
     result.EffectiveState = occurrence.EffectiveState == null ? string.Empty : occurrence.EffectiveState.Name;
 }