public static void SetSSOEndpointUrl(int customerId, string endpointUrl)
 {
     var db = new ClientDataContext();
     var config = db.XAuthConfigurations.Single(c => c.CustomerId == customerId);
     config.SSOServiceEndpointUrl = endpointUrl;
     db.SubmitChanges();
 }
 public void ChangeAllRegsToTestForEvent(int eventId)
 {
     var db = new ClientDataContext();
     int rowsAffected;
     string command = string.Format("UPDATE Registrations SET Test = 1 WHERE Event_Id = {0}", eventId);
     rowsAffected = db.ExecuteCommand(command);
 }
 public static string FetchConfirmationEmailId(int eventId)
 {
     int regMailTriggerId = 1;
     string emailId = string.Empty;
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     var id = (from i in db.RegMailResponders where i.EventId == eventId && i.RegMailTypeId == 2 && i.RegMailTriggerId == regMailTriggerId orderby i.Id descending select i.Id).ToList();
     emailId = id[0].ToString();
     return emailId;
 }
        public static void ApprovedXAuthRoleForCustomer(int customerId, bool isApproved)
        {
            var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);

            string command = string.Format(
                "update XAuthConfiguration set approved='{0}' where CustomerId={1}",
                isApproved,
                customerId);

            db.ExecuteCommand(command);
        }
        public void SelectCountry(bool check, string countryName)
        {
            //E.Countries country = countriesService.GetByDescription(countryName);
            Country country = new Country();

            ClientDataContext db = new ClientDataContext();
            country = (from c in db.Countries where c.Description == countryName select c).Single();

            // The locator of the checkbox of a specific country is "c_" plus the country id
            UIUtil.DefaultProvider.SetCheckbox("c_" + country.CountryId, check, LocateBy.Id);
        }
        public void TestChangeStatusButton()
        {
            this.registrationIds.Clear();
            this.CreateEventAndRegistration();

            //C.Event evt = C.Event.Get(this.eventID);
            //E.TList<E.Registrations> regs = this.regService.GetByEventId(this.eventID);

            Event evt = new Event();
            List<Registration> regs = new List<Registration>();

            ClientDataContext db = new ClientDataContext();
            regs = (from r in db.Registrations where r.Event_Id == this.eventID orderby r.Register_Id descending select r).ToList();
            evt = (from e in db.Events where e.Id == this.eventID select e).Single();

            int FirstRegID = regs[0].Register_Id;
            int SecondRegID = regs[1].Register_Id;
            ReportMgr.SetRegistrationStatus(FirstRegID, 2, evt);
            ReportMgr.SetRegistrationStatus(SecondRegID, 2, evt);

            // set the reg status to some known value
            ReportMgr.SetRegistrationStatus(FirstRegID, 2, evt);

            // pull up the attendee report
            this.LoginAndGetSessionID();
            ManagerSiteMgr.OpenEventDashboardUrl(this.eventID, this.sessionID);
            ManagerSiteMgr.DashboardMgr.ChooseTab(Managers.Manager.Dashboard.DashboardManager.DashboardTab.EventDetails);
            ManagerSiteMgr.DashboardMgr.OpenAttendeeReportFromEventDashboard();

            // select an attendee
            ReportMgr.SelectAttendeeReportRecord(FirstRegID);

            // click the button
            ReportMgr.ClickChangeStatusButton();

            // select statuses dropdown values and click change
            ReportMgr.ChangeStatus(ReportManager.AttendeeStatus.Confirmed, ReportManager.AttendeeStatus.Approved);

            // click OK on the check in confirmation
            ReportMgr.ClickOKOnChangeStatusConfirmationPopup();
            ReportMgr.ClickOKOnChangeStatusConfirmationPopup();

            ReportMgr.SelectReportPopupWindow();

            // verify attendees are checked in
            ReportMgr.VerifyRegistrationStatusOnAttendeeReport(FirstRegID, ReportManager.AttendeeStatus.Approved);

            // cleanup
            ReportMgr.SetRegistrationStatus(FirstRegID, 2, evt);
            UIUtil.DefaultProvider.CloseWindow();
            UIUtil.DefaultProvider.SelectOriginalWindow();
            this.BackToEventList();
        }
        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 static double GetExchangeRate(CurrencyCode currencyCode)
 {
     if (currencyCode == CurrencyCode.USD)
     {
         return 1;
     }
     else
     {
         ClientDataContext db = new ClientDataContext();
         var currency = from c in db.Currencies where c.CurrencyCode.Equals(currencyCode.ToString()) select c;
         return currency.FirstOrDefault().Rate.Value;
     }
 }
        public static void SetLiveRegToTest(List<int> eventIds)
        {
            var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);

            StringBuilder command = new StringBuilder("update Registrations set Test = 1 where Event_Id in (");

            foreach (int id in eventIds)
            {
                command.Append(string.Format("{0},", id.ToString()));
            }

            command.Replace(',', ')', command.Length - 1, 1);

            db.ExecuteCommand(command.ToString());
        }
        public void DeleteRegistrationSession(List<string> registrationSessionIds)
        {
            var db = new ClientDataContext();

            // Step #1: delete those registrations' sessions from clientDB
            foreach (string sessionId in registrationSessionIds)
            {
                string command = string.Format("delete Sessions where Id ='{0}'", sessionId);
                db.ExecuteCommand(command);
            }

            // Step #2: execute stored procedure 'IncompleteRegistrationsCleanup'
            string cleanupCommand = "Exec IncompleteRegistrationsCleanup";
            db.ExecuteCommand(cleanupCommand);
        }
        public Custom_Field GetAgendaItem(int eventId, string agendaItemName)
        {
            Custom_Field agendaItem = null;

            try
            {
                ClientDataContext db = new ClientDataContext();
                agendaItem = (from a in db.Custom_Fields where a.EventId == eventId && a.Description == agendaItemName select a).Single();
            }
            catch
            {
                Assert.Fail("Failed to fetch agenda item '{0}' from database!", agendaItemName);
            }

            return agendaItem;
        }
        public List<Custom_Field> GetAgendaItems(int eventId)
        {
            List<Custom_Field> agendaItems = null;

            try
            {
                ClientDataContext db = new ClientDataContext();
                agendaItems = (from a in db.Custom_Fields where a.EventId == eventId &&
                                   a.LocationId == 0 && a.CategoryID == 2 select a).ToList();
            }
            catch
            {
                Assert.Fail("Failed to fetch agenda items from database!");
            }

            return agendaItems;
        }
        public void VerifyEventConfirmationPage()
        {
            ////ReloadEvent();
            ClientDataContext db = new ClientDataContext();

            Event = (from e in db.Events where e.Id == EventId select e).Single();

            // verify confirmation page
            Assert.That(Event.TellaFriend ?? false);
            Assert.That(Event.SelfReminder ?? false);
            Assert.That(Event.EventCollectionField.Feedback);
            Assert.That(Event.EventCollectionField.EnableAddToMyCalendar);
            Assert.That(Event.MapInConfirmPage ?? false);
            Assert.That(Event.IncludeDirectoryConfirmPage);
            Assert.That(Event.EnableScheduleDownload);
            Assert.IsFalse(Event.BypassConfirmationPage);
        }
 public void ClearPreviousInvoiceData()
 {
     var db = new DataAccess.ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ROMasterConnection);
     int rowsAffected;
     string Command = string.Format(
         "DELETE FROM ct FROM dbo.CustomerTransactions ct INNER JOIN dbo.CustomerInvoices ci ON ci.EndDate = ct.TransDate AND ci.EndDate BETWEEN '{0}' AND '{1}'",
         new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1), DateTimeTool.LastDayOfMonth(DateTime.Now));
     rowsAffected = db.ExecuteCommand(Command);
     Command = string.Format(
         "DELETE  FROM ci FROM dbo.CustomerInvoiceItems cii INNER JOIN dbo.CustomerInvoices ci ON ci.Id = cii.InvoiceId WHERE ci.InvoiceDate BETWEEN '{0}' AND '{1}'",
         new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1), DateTimeTool.LastDayOfMonth(DateTime.Now));
     rowsAffected = db.ExecuteCommand(Command);
     Command = string.Format(
         "DELETE  FROM dbo.CustomerInvoices WHERE InvoiceDate BETWEEN '{0}' AND '{1}'",
         new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1), DateTimeTool.LastDayOfMonth(DateTime.Now));
     rowsAffected = db.ExecuteCommand(Command);
     Command = string.Format(
         @"UPDATE [VSQL2.RegOnline.com\vsql2].ROWarehouse.dbo.ALLDATES SET BUILDSTATUS = 0 WHERE DAYNOW <= '{0}' AND DAYNOW >= '{1}'",
         DateTime.Now, new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1));
     rowsAffected = db.ExecuteCommand(Command);
 }
 public void ApprovedXAuthRoleForCustomer(bool isApproved)
 {
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     db.ExecuteCommand("update XAuthConfiguration set approved='" + isApproved + "' where CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id);
 }
 public void RemoveXAuthTestRegisterAndAttendeeForCustomer()
 {
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     db.ExecuteCommand("UPDATE Registrations Set GroupId=Register_Id,ResourceGroupId=Register_Id WHERE GroupId in (SELECT Registrations.Register_Id FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE IsXAuth=1 AND CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + ")) OR ResourceGroupId in (SELECT Registrations.Register_Id FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE IsXAuth=1 AND CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + "))");
     db.ExecuteCommand("DELETE FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE IsXAuth=1 AND CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + ")");
     db.ExecuteCommand("DELETE FROM Attendees WHERE IsXAuth=1 AND CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id);
 }
        public void RemoveXAuthRoleForCustomer()
        {
            RemoveLiveXAuthEventForCustomer();

            var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
            db.ExecuteCommand("update Attendees set IsXAuth=0 where IsXAuth=1 and CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id);
            db.ExecuteCommand("delete from XAuthConfiguration where CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id);
        }
 public void RemoveTestRegisterAndAttendeeByCustomerIdEmail(string email)
 {
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     db.ExecuteCommand("UPDATE Registrations Set GroupId=Register_Id,ResourceGroupId=Register_Id WHERE GroupId in (SELECT Registrations.Register_Id FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + " AND Email_Address='" + email + "')) OR ResourceGroupId in (SELECT Registrations.Register_Id FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + " AND Email_Address='" + email + "'))");
     db.ExecuteCommand("UPDATE Registrations SET GroupId = 0 WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + " AND Email_Address='" + email + "')");
     db.ExecuteCommand("DELETE FROM Registrations WHERE Attendee_Id IN (SELECT id FROM Attendees WHERE CustomerId= " + ConfigReader.DefaultProvider.AccountConfiguration.Id + " AND Email_Address='" + email + "')");
     db.ExecuteCommand("DELETE FROM Attendees WHERE CustomerId=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + " AND Email_Address='" + email + "'");
 }
        public void SelectEvent()
        {
            int eventId = ManagerBase.InvalidId;

            var db = new ClientDataContext();
            eventId = (from e in db.Events
                       where e.Event_Title.Equals(DefaultEventName)
                       orderby e.Id descending
                       select e.Id).First();

            this.SelectEvent(eventId, DefaultEventName);
        }
        public void VerifyTransactionDataInDB(string[] TransactionAmount, string[] BillableAmount, string[] addAndModBy, string SharedFeePct, EventType type)
        {
            var db = new DataAccess.ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
            var transactions = (from t in db.Transactions where t.RegisterId == regId && t.TypeId == 2 select t).ToList();

            for (int i = 0; i < transactions.Count; i++)
            {
                VerifyTool.VerifyValue(2, transactions[i].TypeId, "Type Id = {0}");
                VerifyTool.VerifyValue(regId, transactions[i].RegisterId, "Register Id = {0}");
                VerifyTool.VerifyValue(TransactionAmount[i], transactions[i].TransAmount.ToString(), "Tansaction Amount = {0}");
                VerifyTool.VerifyValue(GetExchangeRate(eventId), transactions[i].ExchangeRate.ToString(), "Exchange Rate = {0}");

                Event evt = new Event();

                evt = (from e in db.Events where e.Id == eventId select e).Single();

                VerifyTool.VerifyValue(evt.CurrencyCode, transactions[i].CurrencyCode, "Currency Code = {0}");
                VerifyTool.VerifyValue("1", transactions[i].BaseExchangeRate.ToString(), "Base Exchange Rate = {0}");
                VerifyTool.VerifyValue("USD", transactions[i].BaseCurrencyCode, "Base Currency Code = {0}");

                if (i == 0)
                {
                    VerifyTool.VerifyValue(eventId + "-" + regId, transactions[i].TransDoc.ToString(), "Trans Doc = {0}");
                }
                else if (i > 0 && type == EventType.ProEventUpdate)
                {
                    VerifyTool.VerifyValue(eventId + "-" + regId + "-0" + (i), transactions[i].TransDoc.ToString(), "Trans Doc = {0}");
                }
                else
                {
                    VerifyTool.VerifyValue(eventId + "-" + regId + "-0" + i, transactions[i].TransDoc.ToString(), "Trans Doc = {0}");
                }

                // Comment this out: an decryption overflow error happened when trying to decrypt cc number
                ////VerifyTool.VerifyValue(
                ////    TxnIntegrityConstants.ccNumber,
                ////    U.EncryptionTools.ccDecrypt(transactions[i].encryptedccNumber, regId.ToString()),
                ////    "CCnumber = {0}");

                VerifyTool.VerifyValue(TxnIntegrityConstants.ccExpDate, transactions[i].ccExpDate.ToString(), "CC Exp date = {0}");
                VerifyTool.VerifyValue(TxnIntegrityConstants.ccName, transactions[i].ccName, "CC name = {0}");
                VerifyTool.VerifyValue(TxnIntegrityConstants.ccType, transactions[i].ccType, "CC type = {0}");
                VerifyTool.VerifyValue(TxnIntegrityConstants.MerchandId, transactions[i].MerchantId, "Merchant Id = {0}");
                VerifyTool.VerifyValue(addAndModBy[i], transactions[i].Add_By, "Add By = {0}");
                VerifyTool.VerifyValue(addAndModBy[i], transactions[i].Mod_By, "Mod By = {0}");
                VerifyTool.VerifyValue(TxnIntegrityConstants.LastFourCC, transactions[i].last4CCDigits.ToString(), "Last 4 CC digits {0}");
                VerifyTool.VerifyValue(true, transactions[i].authCode != null, "Auth code is not null = {0}");
                VerifyTool.VerifyValue(SharedFeePct, transactions[i].SharedFeePct.ToString(), "Shared Fee Percent = {0}");

                if (type != EventType.Endurance_USD)
                {
                    VerifyTool.VerifyValue(TxnIntegrityConstants.CustomerMerchantId, transactions[i].CustomerMerchantId.ToString(), "Customer Merchand Id = {0}");
                }
                else
                {
                    VerifyTool.VerifyValue(TxnIntegrityConstants.EnduranceCustomerMerchId, transactions[i].CustomerMerchantId.ToString(), "Customer Merchand Id = {0}");
                    VerifyTool.VerifyValue(TxnIntegrityConstants.EnduranceMerchAmount, transactions[i].MerchAmount.ToString(), "Merch Amount = {0}");
                    VerifyTool.VerifyValue(TxnIntegrityConstants.EnduranceNonMerchAmount, transactions[i].NonMerchAmount.ToString(), "Non-Merch Amount = {0}");
                }

                VerifyTool.VerifyValue(BillableAmount[i], transactions[i].BillableAmount.ToString(), "Billable Amount = {0}");
                VerifyTool.VerifyValue(true, transactions[i].GatewayTransactionId != null, "Gateway Transaction Id is not null = {0}");
            }
        }
 // Gets the exchange rate for an event. Keep an eye on it as eventually you might be able to do this from core
 public string GetExchangeRate(int eventID)
 {
     ClientDataContext db = new ClientDataContext();
     return (from c in db.Events where c.Id == eventID select c).Single().CurrencyCode;
 }
 public void RemoveLiveXAuthEventForCustomer()
 {
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     db.ExecuteCommand("update EventRegTypes set xauthenabled=0 where xauthenabled=1 and eventid in (select id from events where customer_id=" + ConfigReader.DefaultProvider.AccountConfiguration.Id + ")");
 }
 private DateTime GetEventCreatedTime(int id)
 {
     //get created time
     //S.EventsService ets = new S.EventsService();
     //E.Events et = ets.GetById(id);
     ClientDataContext db = new ClientDataContext();
     Event et = (from e in db.Events where e.Id == id select e).Single();
     return et.Add_Date;
 }
        /// <summary>
        /// Change the transactions of specified registrant to one day ago to settle them
        /// </summary>
        /// <param name="registerId"></param>
        public void ChangeTransactionDateToSettle(int registerId)
        {
            ClientDataContext db = new ClientDataContext();

            List<Transaction> transactions = (from t in db.Transactions where t.RegisterId == registerId select t).ToList();

            foreach (Transaction t in transactions)
            {
                if (t.TransDate.HasValue)
                {
                    t.TransDate = t.TransDate.Value.AddDays(-1);
                }
            }

            db.SubmitChanges();
        }
        public int GetRegIdFromSession()
        {
            string sessionID = this.GetSessionId();
            int eventId = this.GetEventId();
            int regId = 0;

            var db = new ClientDataContext();
            var register = (from r in db.Registrations where r.Event_Id == eventId && r.SessionId == sessionID orderby r.Register_Id ascending select r).ToList().Last();
            regId = register.Register_Id;

            if (regId == 0)
            {
                UIUtil.DefaultProvider.FailTest("Invalid reg ID!");
            }

            return regId;
        }
        public void SetGroupDiscountPopUpMessage(int eventID, string message)
        {
            // If there is no custom pop up message use default message
            if (message == null)
            {
                UIUtil.DefaultProvider.WaitForDisplayAndClick("restore default", LocateBy.LinkText);
            }
            else
            {
                //S.DiscountRulesService discountRuleService = new S.DiscountRulesService();
                //E.TList<E.DiscountRules> discountRules = discountRuleService.GetByEventId(eventID);
                List<DiscountRule> discountRules = new List<DiscountRule>();

                ClientDataContext db = new ClientDataContext();
                discountRules = (from d in db.DiscountRules where d.EventId == eventID select d).ToList();

                if (discountRules.Count > 0)
                {
                    foreach (DiscountRule discountRule in discountRules)
                    {
                        if (discountRule.isCurrent)
                        {
                            discountRule.Reg_Description = Convert.ToString(message);
                            db.SubmitChanges();
                            //discountRuleService.Save(discountRule);
                            break;
                        }
                    }
                }
            }
        }
 public string GetAttendeeId(int listId)
 {
     ClientDataContext db = new ClientDataContext();
     return Convert.ToString((from a in db.Attendees where a.ListId == listId orderby a.Id ascending select a).ToList().Last().Id);
 }
 /// <summary>
 /// Make the transactions for this registrant, the start of yesterday, so the Void button goes away
 /// </summary>
 /// <param name="registrationId"></param>
 public void PullBackTransaction(int registrationId)
 {
     var db = new ClientDataContext(ConfigReader.DefaultProvider.EnvironmentConfiguration.ClientDbConnection);
     db.ExecuteCommand(string.Format("update Transactions set transdate='{0}' where RegisterId={1}",
         DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy"),
         registrationId));
 }
        public void VerifyEventCheckoutPage()
        {
            ////this.ReloadEvent();
            ClientDataContext db = new ClientDataContext();

            Event = (from e in db.Events where e.Id == EventId select e).Single();

            // verify payment options
            Assert.That(Event.Capture_Payment);
            Assert.IsFalse(Event.CapturePaymentOnZero ?? false);
            VerifyTool.VerifyValue("USD", Event.CurrencyCode, "Event currency code: {0}");
            VerifyTool.VerifyValue("Active Events AKA RegOnline", Event.InvoiceCompany, "Event invoice company: {0}");
            Assert.That(Event.GenerateInvoice ?? false);

            // verify cc options
            Assert.That(Event.Charge_Online);
            VerifyTool.VerifyValue(1218, Event.customerMerchantId, "CustomerMerchantId: {0}");
            VerifyTool.VerifyValue("Active Events AKA RegOnli", Event.DynamicDescriptor, "Event dynamic descriptor: {0}");
            Assert.IsFalse(Event.DontChargeCC ?? false);
            Assert.That(Event.storeCCNumbers);
            Assert.That(Event.EventCollectionField.cCVVCode ?? false);
            Assert.That(Event.EventCollectionField.rCVVCode ?? false);

            // verify payment methods
            for (int i = 1; i <= 14; i++)
            {
                // skip e-check
                if (i == 12)
                {
                    continue;
                }

                // "Cash" payment method not available to public
                bool publicReg = i != 8;

                Event_Payment_Method method = null;

                ClientDataContext clientDb = new ClientDataContext();
                method = (from p in clientDb.Event_Payment_Methods where p.Event == Event && p.Payment_Method_Id == i select p).Single();
                //E.Event method = Event.Event_Payment_Methods.Find(
                //    delegate(E.EventPaymentMethods methodInner)
                //    {
                //        return methodInner.PaymentMethodId == i &&
                //            (methodInner.PublicReg ?? false) == publicReg &&
                //            (methodInner.AdminReg ?? false);
                //    }
                //);

                Assert.That(method != null);

                // additional verification for "Custom" payment method
                if (i == 13)
                {
                    Assert.That(method.customDescription == "custom");
                    Assert.That(method.DisplayTextbox);
                }
            }
        }
        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;
            }
        }