Beispiel #1
0
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        // check to see if there's a restriction
        string contactTypeID = ddlType.SelectedValue;

        using (var api = GetServiceAPIProxy())
        {
            var restriction = api.CheckForExhibitorContactRestriction(targetExhibitor.ID, contactTypeID).ResultValue;
            if (restriction != null && restrictionHasBeenViolated(restriction.ConvertTo <msExhibitorContactRestriction>()))
            {
                cvContactRestriction.ErrorMessage = restriction.SafeGetValue <string>("ErrorMessage") ??
                                                    "Unable to add contact - a restriction is in place: " +
                                                    restriction["Name"];
                cvContactRestriction.IsValid = false;
                return;
            }
        }

        if (targetContact == null)
        {
            targetContact = new msExhibitorContact();
            if (targetExhibitor.Contacts == null)
            {
                targetExhibitor.Contacts = new List <msExhibitorContact>();
            }

            targetExhibitor.Contacts.Add(targetContact);
        }
        targetContact.Type         = ddlType.SelectedValue;
        targetContact.FirstName    = tbFirstName.Text;
        targetContact.LastName     = tbLastName.Text;
        targetContact.EmailAddress = tbEmail.Text;
        targetContact.WorkPhone    = tbWorkPhone.Text;
        targetContact.MobilePhone  = tbMobilePhone.Text;
        targetContact["Title"]     = tbTitle.Text;


        SaveObject(targetExhibitor);

        GoTo("ViewExhibitor.aspx?contextID=" + ContextID, "The contact has been saved successfully.");
    }
Beispiel #2
0
    protected override void InitializeTargetObject()
    {
        base.InitializeTargetObject();
        targetExhibitor = LoadObjectFromAPI <msExhibitor>(ContextID);
        if (targetExhibitor == null)
        {
            GoToMissingRecordPage();
        }

        targetShow = LoadObjectFromAPI <msExhibitShow>(targetExhibitor.Show);
        if (targetShow == null)
        {
            GoToMissingRecordPage();
        }

        int index;

        if (int.TryParse(Request.QueryString["itemIndex"], out index) && targetExhibitor.Contacts != null &&
            targetExhibitor.Contacts.Count >= index)
        {
            targetContact = targetExhibitor.Contacts[index];
        }
    }