Exemple #1
0
        public void GetContacts_Test()
        {
            ContactData target       = new ContactData();
            Contacts    testContacts = target.GetContacts();

            Assert.IsTrue(testContacts.Count > 0);
        }
Exemple #2
0
        /// <summary>
        /// Gets a <see cref="Contact"/> object
        /// </summary>
        /// <param name="contactCode">The code of the contact to extract</param>
        /// <returns>A <see cref="Contact"/> object</returns>
        /// <exception cref="ArgumentException">When the <paramref name="contactCode"/> is empty or null</exception>
        /// <exception cref="DataException">When the <paramref name="contactCode"/> does not yield any results in the lookup operation</exception>
        public Contact GetContactObject(string contactCode)
        {
            if (string.IsNullOrWhiteSpace(contactCode))
            {
                throw new ArgumentException("Invalid contact code, cannot be empty or null");
            }
            var data    = ContactData.GetContacts();
            var contact = data.SingleOrDefault(i => i.Code.ToLowerInvariant().Equals(contactCode.ToLowerInvariant()));

            if (contact == null)
            {
                throw new DataException("Provided code does not returns a valid contact");
            }
            return(contact);
        }
Exemple #3
0
        public List <Contact> GetContactsDetails()
        {
            Contact     contact = new Contact();
            string      con     = ConfigurationManager.ConnectionStrings["myConnectionString"].ToString();
            ContactData dal     = new ContactData(con);

            try
            {
                return(dal.GetContacts());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(null);
        }