Esempio n. 1
0
        public static List<int> GetEventTypesList(EventAdminDetailView parent, SubEntity subEntity)
        {
            var eventTypeIds = subEntity.Records.Where(e => e.Id > 0 && e.Action != RecordActions.Deleted).Select(e => e.Id).ToList();

            //Add any newly created topics
            var newTopics = subEntity.Records.Where(e => e.Action == RecordActions.New);
            foreach (var newTopic in newTopics)
            {
                var request = new AddEventTypeRequest()
                {
                    Name = CommonUtils.GetFieldValue(newTopic.Fields, _eventType),
                    IsEnabled = true
                };
                var response = parent.ProcessRequest<AddEventTypeResponse>(request);
                eventTypeIds.Add(response.Id);
            }

            if (eventTypeIds.Count <= 0)
            {
                const string errorMessage = "Event Type required";
                subEntity.ErrorMessage = errorMessage;
                throw new Exception(errorMessage);
            }

            return eventTypeIds;
        }
        public static List<SubEntityRecord> GetDropdownValues(EventAdminDetailView parent, int eventId)
        {
            var existingPrerequisites = new List<EventPrerequisiteDto>();
            if (eventId != 0)
                existingPrerequisites = GetEventPrerequisites(parent, eventId);

            var request = new ListEventsRequest() { };
            var events = parent.ProcessRequest<ListEventsResponse>(request).Events;
            var records = new List<SubEntityRecord>();

            foreach (var item in events.Where(s => !existingPrerequisites.Any(e => e.AssociatedEventId == s.Id)))
            {
                var record = new SubEntityRecord();
                record.DisplayName = item.Title;
                record.Id = item.Id;

                record.Fields.Add(new Field(_id, "Id", FieldTypes.Hidden, null));
                record.Fields.Add(new Field(_associatedEventId, "EventId", FieldTypes.Hidden, item.Id));
                record.Fields.Add(new Field(_eventTitle, "Event Title", FieldTypes.Label, item.Title));
                record.Fields.Add(new Field(_prerequisiteDescription, "Description", FieldTypes.WYSIWYG, string.Empty));
                record.Fields.Add(new Field(_prerequisiteOrder, "Order ", FieldTypes.Text, string.Empty, true));

                records.Add(record);
            }

            return records;
        }
        private static void AddExistingRecords(EventAdminDetailView parent, int providerId)
        {
            var request = new ListDirectUrlHistoryRequest() { EntityId = providerId, EntityTypeId = EntityTypeId.Event };
            var urlHistoryLinks = parent.ProcessRequest<ListDirectUrlHistoryResponse>(request).DirectUrlHistory;

            foreach (var directUrl in urlHistoryLinks)
            {
                var record = new SubEntityRecord();
                var fields = new List<Field>();

                fields.Add(new Field(_id, _id, FieldTypes.Hidden, directUrl.Id));
                fields.Add(new Field(_directUrl, directUrl.DateAdded.ToString("M/d/yy h:m:s tt"), FieldTypes.Label, directUrl.DirectUrl));

                record.Fields = fields;

                _subEntity.Records.Add(record);
            }
        }
Esempio n. 4
0
        public static void Save(EventAdminDetailView parent, SubEntity eventContent, int eventId)
        {
            try
            {
                var record = eventContent.Records.FirstOrDefault(r => r.Action == RecordActions.Edited);

                if (record != null)
                {
                    var updateRequest = new UpdateEventContentRequest
                    {
                        EventId = eventId,
                        Content = parent.GetFieldValue(record.Fields, "Content")
                    };

                    parent.ProcessRequest<UpdateEventContentResponse>(updateRequest);
                }
            }
            catch (Exception ex)
            {
                eventContent.ErrorMessage = ex.Message;
                throw;
            }
        }
        public static void Save(EventAdminDetailView parent, SubEntity directUrls, int providerId)
        {
            try
            {
                directUrls.ErrorMessage = string.Empty;

                //Deletes
                foreach (var record in directUrls.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteDirectUrlHistoryRequest()
                    {
                        Id = int.Parse(parent.GetFieldValue(record.Fields, _id))
                    };
                    parent.ProcessRequest<DeleteDirectUrlHistoryResponse>(request);
                }
            }
            catch (Exception ex)
            {
                directUrls.ErrorMessage = ex.Message;
                throw;
            }

            directUrls = BuildSubEntity(parent, providerId);
        }
        private static void AddExistingRecords(EventAdminDetailView parent, EventDto eventDto)
        {
            if (!eventDto.DynamicFormsId.HasValue)
                return;

            var dynamicFormId = eventDto.DynamicFormsId.Value;

            var formRequest = new ReadDynamicFormRequest { FormId = dynamicFormId };
            var formResponse = parent.ProcessRequest<ReadDynamicFormResponse>(formRequest);

            var record = new SubEntityRecord { Id = dynamicFormId };
            var fields = new List<Field>();

            fields.Add(new Field(_formName, "Registration Form Name", FieldTypes.Label, formResponse.Form.Name));
            fields.Add(new Field(_registrationFormLink, string.Empty, FieldTypes.Html, string.Format(_registrationFormLinkAnchorTag, eventDto.DynamicFormsId)));
            record.Fields = fields;

            _subEntity.Records.Add(record);
        }
        internal static void Save(EventAdminDetailView parent, SubEntity subentity, int _eventId)
        {
            try
            {
                subentity.ErrorMessage = string.Empty;

                if (subentity.Records.Where(r => r.Action == null || r.Action == RecordActions.Added).Count() > 1)
                    throw new Exception("Only 1 Registration Form is allowed");

                foreach (var record in subentity.Records)
                {
                    int? formId;

                    if (record.Action == RecordActions.Deleted)
                        formId = null;
                    else
                        formId = record.Id;

                    var request = new UpdateEventDynamicFormRequest { EventId = _eventId, DynamicFormId = formId };
                    parent.ProcessRequest<UpdateEventDynamicFormResponse>(request);
                }
            }
            catch (Exception ex)
            {
                subentity.ErrorMessage = ex.Message;
                throw;
            }
        }
 private static List<DynamicFormDto> GetAllForms(EventAdminDetailView parent)
 {
     var request = new ListDynamicFormsTemplatesRequest() { ListAllForms = true };
     return parent.ProcessRequest<ListDynamicFormsTemplatesResponse>(request).Templates.ToList();
 }
Esempio n. 9
0
        private static List<EventTypeDto> GetEventTypes(EventAdminDetailView parent, int eventId)
        {
            var request = new ReadEventRequest() { Id = eventId };
            var typeAssociations = parent.ProcessRequest<ReadEventResponse>(request).Event.EventTypeAssociations;

            IEnumerable<EventTypeDto> eventTypes;
            List<SubEntityRecord> records;
            GetAllEventTypes(parent, out eventTypes, out records);

            return eventTypes.Where(s => typeAssociations.Any(e => e.EventTypeId == s.Id)).ToList();
        }
Esempio n. 10
0
 private static void GetAllEventTypes(EventAdminDetailView parent, out IEnumerable<EventTypeDto> eventTypes, out List<SubEntityRecord> records)
 {
     var request = new ListEventTypesRequest() { IsEnabled = true };
     eventTypes = parent.ProcessRequest<ListEventTypesResponse>(request).EventTypes;
     records = new List<SubEntityRecord>();
 }
Esempio n. 11
0
 private static EventDto GetEvent(EventAdminDetailView parent, int eventId)
 {
     var request = new ReadEventRequest() { Id = eventId };
     return parent.ProcessRequest<ReadEventResponse>(request).Event;
 }
        public static void Save(EventAdminDetailView parent, SubEntity eventPrereqs, int eventId)
        {
            try
            {
                eventPrereqs.ErrorMessage = string.Empty;

                //Edits
                foreach (var record in eventPrereqs.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    CheckRequiredFields(record);

                    var request = new UpdateEventPrerequisiteRequest
                    {
                        Id = int.Parse(parent.GetFieldValue(record.Fields, _id)),
                        EventId = eventId,
                        AssociatedEventId = int.Parse(parent.GetFieldValue(record.Fields, _associatedEventId)),
                        Description = parent.GetFieldValue(record.Fields, _prerequisiteDescription),
                        DisplayOrder = int.Parse(parent.GetFieldValue(record.Fields, _prerequisiteOrder))
                    };

                    parent.ProcessRequest<UpdateEventPrerequisiteResponse>(request);
                }

                //Existing Records Added
                foreach (var record in eventPrereqs.Records.Where(r => r.Action == RecordActions.Added))
                {
                    CheckRequiredFields(record);

                    var request = new AddEventPrerequisiteRequest
                        {
                            EventId = eventId,
                            AssociatedEventId = int.Parse(parent.GetFieldValue(record.Fields, _associatedEventId)),
                            Description = parent.GetFieldValue(record.Fields, _prerequisiteDescription),
                            DisplayOrder = int.Parse(parent.GetFieldValue(record.Fields, _prerequisiteOrder))
                        };
                    parent.ProcessRequest<AddEventPrerequisiteResponse>(request);
                }

                //Records Deleted
                foreach (var record in eventPrereqs.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteEventPrerequisiteRequest()
                    {
                        Id = int.Parse(parent.GetFieldValue(record.Fields, _id)),
                    };
                    parent.ProcessRequest<DeleteEventPrerequisiteResponse>(request);
                }
            }
            catch (Exception ex)
            {
                eventPrereqs.ErrorMessage = ex.Message;
                throw;
            }

            eventPrereqs = BuildSubEntity(parent, eventId);
        }
 private static List<EventPrerequisiteDto> GetEventPrerequisites(EventAdminDetailView parent, int eventId)
 {
     var request = new ListEventPrerequisitesRequest() { EventId = eventId };
     return parent.ProcessRequest<ListEventPrerequisitesResponse>(request).EventPrerequisites.ToList();
 }