Exemplo n.º 1
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);
        }
        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);
        }