/// <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()) { emailTemplateContainerClassMetadata = proxy.DescribeObject(msEmailTemplateContainer.CLASS_NAME).ResultValue; emailTemplateContainerFieldMetadata = emailTemplateContainerClassMetadata.GenerateFieldDictionary(); } var contextObject = APIExtensions.LoadObjectFromAPI(ContextID); if (contextObject.ClassType == msEvent.CLASS_NAME) { targetEvent = contextObject.ConvertTo <msEvent>(); targetEmailTemplateContainer = msEmailTemplateContainer.FromClassMetadata(emailTemplateContainerClassMetadata); targetEmailTemplateContainer.Template = new EmailTemplate { SearchType = "EventRegistration" }; lblTitleAction.Text = "Create"; } else { targetEmailTemplateContainer = contextObject.ConvertTo <msEmailTemplateContainer>(); targetEvent = LoadObjectFromAPI <msEvent>(targetEmailTemplateContainer.Context); if (targetEmailTemplateContainer.Template == null) { targetEmailTemplateContainer.Template = new EmailTemplate { SearchType = "EventRegistration" } } ; lblTitleAction.Text = "Edit"; } if (targetEvent == null || targetEmailTemplateContainer == null) { GoToMissingRecordPage(); return; } targetEmailTemplateContainer.Context = targetEmailTemplateContainer.Template.SearchContext = targetEvent.ID; loadEventOwners(); }
protected void unbindAndSave() { unbindEventDiscountCode(); targetEmailTemplateContainer = SaveObject(targetEmailTemplateContainer).ConvertTo <msEmailTemplateContainer>(); }