public void delete_invalid_prerequisite()
        {
            var handler = CreateDeleteHandler();

            // delete an invalid request
            var deleteRequest = new DeleteEventPrerequisiteRequest
            {
                Id = 0
            };

            var deleteResponse = HandleRequest<AddEventPrerequisiteResponse>(handler, deleteRequest);
        }
        public void delete_prerequisite()
        {
            // add a request
            var addHandler = CreateAddHandler();

            var addRequest = new AddEventPrerequisiteRequest
            {
                EventId = 2,
                AssociatedEventId = 1,
                Description = "This is a mandatory prerequisite."
            };

            var addResponse = HandleRequest<AddEventPrerequisiteResponse>(addHandler, addRequest);

            // delete the newly added request
            var deleteHandler = CreateDeleteHandler();

            var deleteRequest = new DeleteEventPrerequisiteRequest
            {
                Id = addResponse.Id
            };

            var deleteResponse = HandleRequest<DeleteEventPrerequisiteResponse>(deleteHandler, deleteRequest);
        }
        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);
        }