Exemple #1
0
        internal bool DoesCustomerExist(int personID)
        {
            bool doesCustomerExist = false;

            //instantiate DAO
            BaseDataAccess <Dto.Person> personDAO =
                new BaseDataAccess <Dto.Person>(_databaseSmoObjectsAndSettings);

            //instantiate dto
            Dto.Person personDTO = new Dto.Person();

            Bo.Person personToReturn = new Bo.Person(_databaseSmoObjectsAndSettings);

            //set the property, in this case we are going to use this as the search criteria
            personDTO.PersonID = personID;

            //we know that the criteria that we set is the primary key of the database table, so
            //choose that as the search permutation
            List <Dto.Person> listOfPersons =
                personDAO.Get(personDTO, GetPermutations.ByPrimaryKey);

            if (listOfPersons.Count > 0)
            {
                doesCustomerExist = true;
            }

            return(doesCustomerExist);
        }
Exemple #2
0
        internal Person GetExistingCustomer(int personId, ref List <Address> addresses, ref List <Contact> contacts)
        {
            //instantiate DAO
            BaseDataAccess <Dto.Person> personDAO =
                new BaseDataAccess <Dto.Person>(_databaseSmoObjectsAndSettings);

            //instantiate dto
            Dto.Person personDTO = new Dto.Person();

            Bo.Person personToReturn = new Bo.Person(_databaseSmoObjectsAndSettings);

            //set the property, in this case we are going to use this as the search criteria
            personDTO.PersonID = personId;

            //we know that the criteria that we set is the primary key of the database table, so
            //choose that as the search permutation
            List <Dto.Person> listOfPersons =
                personDAO.Get(personDTO, GetPermutations.ByPrimaryKey);

            if (listOfPersons != null)
            {
                //there should only be one
                if (listOfPersons.Count == 1)
                {
                    personToReturn.PersonID = personId;

                    personToReturn.GetByPrimaryKey();

                    addresses = GetExistingAddresses(personId);
                    contacts  = GetExistingContacts(personId);

                    return(personToReturn);
                }
                else
                {
                    throw new ApplicationException(MORE_THAN_ONE_PERSON_RECORD_RETURNED_ERROR_MESSAGE);
                }
            }
            else
            {
                //if there is no person then there cannot be dependent address or contact records
                return(personToReturn);
            }
        }