public IEnumerable <Contact> GetAllContacts() { IEnumerable <Contact> lstContact = null; connection.Open(); SqlCommand command = new SqlCommand(CommonConstants.SP_CONTACT_GETALLCONTACTS, connection); command.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader result = command.ExecuteReader(); lstContact = ContactEngineHelper.MapContactToReader(result); return(lstContact); }
public Contact GetContactByID(int contactID) { Contact contact = new Contact(); connection.Open(); SqlCommand cmd = new SqlCommand(CommonConstants.SP_CONTACT_GETCONTACTBYID, connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ContactID", DbType.Int32).Value = contactID; SqlDataReader reader = cmd.ExecuteReader(); contact = ContactEngineHelper.MapContactToReader(reader).FirstOrDefault(); connection.Close(); return(contact); }