/// <summary> /// Initializes the target object for the page /// </summary> /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing /// an event, the target object is an event. When looking up a directory, that's the target /// object. This method is intended to be overriden to initialize the target object for /// each page that needs it.</remarks> protected override void InitializeTargetObject() { base.InitializeTargetObject(); //Describe an Event Discount Code. We will need this metadata to bind to the acceptable values for certain fields and for creating a new Discount / Promo Code using (IConciergeAPIService proxy = GetConciegeAPIProxy()) { customFieldClassMetadata = proxy.DescribeObject(msCustomField.CLASS_NAME).ResultValue; customFieldFieldMetadata = customFieldClassMetadata.GenerateFieldDictionary(); } var contextObject = APIExtensions.LoadObjectFromAPI(ContextID); if (contextObject.ClassType == msEvent.CLASS_NAME) { targetEvent = contextObject.ConvertTo <msEvent>(); targetCustomField = msCustomField.FromClassMetadata(customFieldClassMetadata); targetCustomField.FieldDefinition = new FieldMetadata(); lblTitleAction.Text = "Create"; isInEditMode = false; } else { targetCustomField = contextObject.ConvertTo <msCustomField>(); targetEvent = LoadObjectFromAPI <msEvent>(targetCustomField.Event); if (targetCustomField.FieldDefinition == null) { targetCustomField.FieldDefinition = new FieldMetadata(); } lblTitleAction.Text = "Edit"; isInEditMode = true; } if (targetEvent == null || targetCustomField == null) { GoToMissingRecordPage(); return; } targetCustomField.Event = targetEvent.ID; targetCustomField.ApplicableType = "DEMOGRAPHIC"; targetCustomField.Type = CustomFieldType.EventRegistration; loadEventOwners(); }
protected void unbindAndSave() { unbindCustomField(); targetCustomField = SaveObject(targetCustomField).ConvertTo <msCustomField>(); }