private void AddCustomField(
     CustomFieldManager.CustomFieldLocation cfLocation,
     CustomFieldManager.CustomFieldType type, 
     string name)
 {
     this.ClickAddCustomField(cfLocation);
     CFMgr.SetName(name);
     CFMgr.SetTypeWithDefaults(type);
     CFMgr.SaveAndClose();
 }
        private void ClickAddCustomField(CustomFieldManager.CustomFieldLocation cfLocation)
        {
            string linkLocator;

            switch (cfLocation)
            {
                case CustomFieldManager.CustomFieldLocation.PI:
                    linkLocator = this.GetAddGridItemLocator(PIPageAddCFLinkLocatorPrefix);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Lodging:
                    linkLocator = this.GetAddGridItemLocator(LTPageAddLodgingCFLinkLocatorPrefix);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Travel:
                    linkLocator = this.GetAddGridItemLocator(LTPageAddTravelCFLinkLocatorPrefix);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Preferences:
                    linkLocator = this.GetAddGridItemLocator(LTPageAddPreferenceCFLinkLocatorPrefix);
                    break;

                default:
                    throw new Exception(string.Format("Invalid custom field location: '{0}'", cfLocation.ToString()));
            }

            UIUtil.DefaultProvider.WaitForDisplayAndClick(linkLocator, LocateBy.Id);
            Utility.ThreadSleep(1);
            UIUtil.DefaultProvider.WaitForAJAXRequest();
            UIUtil.DefaultProvider.SelectPopUpFrameByName(CFFrameID);

            switch (cfLocation)
            {
                case CustomFieldManager.CustomFieldLocation.PI:
                    this.ResizeCustomFieldRADWindowAndAdjustPosition(1000, 800, 20, 800);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Lodging:
                    this.ResizeCustomFieldRADWindowAndAdjustPosition(1000, 800, 20, 600);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Travel:
                    this.ResizeCustomFieldRADWindowAndAdjustPosition(1000, 800, 20, 1700);
                    break;

                case CustomFieldManager.CustomFieldLocation.LT_Preferences:
                    this.ResizeCustomFieldRADWindowAndAdjustPosition(1000, 800, 20, 20);
                    break;

                default:
                    break;
            }
        }
        public List<Custom_Field> Fetch_CustomFieldsFor(
            int eventId, 
            CustomFieldManager.CustomFieldCategory category, 
            CustomFieldManager.CustomFieldLocation location, 
            bool adminOnly)
        {
            ClientDataContext db = new ClientDataContext();

            return (from c in db.Custom_Fields where c.EventId == eventId &&
                        c.CategoryID == (int)category && c.LocationId == (int)location &&
                        c.AdminOnly == adminOnly select c).ToList();
        }
 private void AddAndVerifyTravelCustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     BuilderMgr.AddTravelCustomField(type, name);
     BuilderMgr.VerifyTravelCustomFieldInDatabase(type, name);
 }
 private void AddAndVerifyPersonalInfoCustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     BuilderMgr.AddPICustomField(type, name);
     BuilderMgr.VerifyPersonalInfoCustomFieldInDatabase(type, name);
 }
 private void LodgingCustomField(CustomFieldManager.CustomFieldType type, string name, bool prePopulate, bool groupEdit)
 {
     BuilderMgr.CFMgr.SetName(name);
     BuilderMgr.CFMgr.SetType(type);
     if (type == CustomFieldManager.CustomFieldType.Dropdown || type == CustomFieldManager.CustomFieldType.RadioButton)
     {
         BuilderMgr.CFMgr.AddPredefinedMultiChoiceItem(PredifinedMultiChoiceItemManagerBase.PredefinedItemType.OneToTen);
     }
     if (type == CustomFieldManager.CustomFieldType.Number || type == CustomFieldManager.CustomFieldType.OneLineText)
     {
         BuilderMgr.CFMgr.SetOneLineLength(25);
     }
     if (type == CustomFieldManager.CustomFieldType.Paragraph)
     {
         BuilderMgr.CFMgr.SetParagraphCharacterLimit(10000);
     }
     UIUtil.DefaultProvider.ExpandAdvanced();
     BuilderMgr.CFMgr.PrePopulateGroupSelections(prePopulate);
     if (groupEdit)
     {
         BuilderMgr.CFMgr.AllowGroupSelectionEditing(groupEdit);
     }
     BuilderMgr.CFMgr.SaveAndClose();
 }
        private void VerifyCustomFieldInDatabase(CustomFieldManager.CustomFieldType type, string name, int location)
        {
            List<Custom_Field> cf = null;

            ClientDataContext db = new ClientDataContext();

            cf = (from c in db.Custom_Fields
                  where c.Description == name && c.LocationId == location && c.TypeId == (int)type
                  orderby c.Id ascending
                  select c).ToList();

            Assert.That(cf.Count != 0);

            switch (type)
            {
                case CustomFieldManager.CustomFieldType.RadioButton:
                case CustomFieldManager.CustomFieldType.Dropdown:
                    Assert.That(cf.Last().Custom_Field_List_Items != null);
                    break;
                case CustomFieldManager.CustomFieldType.Number:
                case CustomFieldManager.CustomFieldType.OneLineText:
                    Assert.That(cf.Last().Length == ((int)type == 2 ? 50 : 5));
                    break;
            }
        }
 public void VerifyTravelCustomFieldInDatabase(CustomFieldManager.CustomFieldType type, string name)
 {
     VerifyCustomFieldInDatabase(type, name, 3);
 }
 public void VerifyLodgingCustomFieldInDatabase(CustomFieldManager.CustomFieldType type, string name)
 {
     this.VerifyCustomFieldInDatabase(type, name, 2);
 }
 public void VerifyPreferencesCustomFieldInDatabase(CustomFieldManager.CustomFieldType type, string name)
 {
     VerifyCustomFieldInDatabase(type, name, 4);
 }
 public void AddTravelCustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     AddCustomField(CustomFieldManager.CustomFieldLocation.LT_Travel, type, name);
     UIUtil.DefaultProvider.WaitForPageToLoad();
 }
 public void AddPreferencesCustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     this.AddCustomField(CustomFieldManager.CustomFieldLocation.LT_Preferences, type, name);
 }
 public void AddLodgingCustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     this.AddCustomField(CustomFieldManager.CustomFieldLocation.LT_Lodging, type, name);
     UIUtil.DefaultProvider.WaitForPageToLoad();
 }
 public void VerifyPersonalInfoCustomFieldInDatabase(CustomFieldManager.CustomFieldType type, string name)
 {
     VerifyCustomFieldInDatabase(type, name, 1);
 }
 public void AddPICustomField(CustomFieldManager.CustomFieldType type, string name)
 {
     this.AddCustomField(CustomFieldManager.CustomFieldLocation.PI, type, name);
 }