Esempio n. 1
0
        /// <summary>
        /// Get all Profiles
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public List <ProfileDTO> FindProfiles(int pageIndex, int pageCount)
        {
            if (pageIndex < 0 || pageCount <= 0)
            {
                throw new ArgumentException(Messages.warning_InvalidArgumentForFindProfiles);
            }

            //recover profiles in paged fashion
            var profiles     = _profileRepository.GetPaged <DateTime>(pageIndex, pageCount, o => o.Created, false);
            var addressTypes = _addressTypeRepository.GetAll().ToList();
            var phoneTypes   = _phoneTypeRepository.GetAll().ToList();

            if (profiles != null
                &&
                profiles.Any())
            {
                List <ProfileDTO> lstProfileDTO = new List <ProfileDTO>();
                foreach (var profile in profiles)
                {
                    lstProfileDTO.Add(Conversion.Mapping.ProfileToProfileDTO(profile, addressTypes, phoneTypes));
                }
                return(lstProfileDTO);
            }
            else // no data
            {
                return(new List <ProfileDTO>());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get all profiles
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public List <ProfileDTO> FindProfiles(int pageIndex, int pageCount)
        {
            if (pageIndex < 0 || pageCount <= 0)
            {
                throw new ArgumentException(Messages.warning_InvalidArgumentForFindProfiles);
            }

            // Recover profiles in paged fashion
            List <Profile> profiles = _profileRepository.GetPaged <DateTime>(pageIndex, pageCount, o => o.Created, false).ToList();

            if (profiles != null && profiles.Any())
            {
                List <AddressType> addressTypes = _addressTypeRepository.GetAll().ToList();
                List <PhoneType>   phoneTypes   = _phoneTypeRepository.GetAll().ToList();
                List <ProfileDTO>  profilesDto  = new List <ProfileDTO>();

                foreach (var profile in profiles)
                {
                    profilesDto.Add(Mapping.ProfileToProfileDTO(profile, addressTypes, phoneTypes));
                }

                return(profilesDto);
            }

            return(new List <ProfileDTO>());
        }