Exemple #1
0
        public Paged <JobWithDistance> SearchNearby(string Query, int PageIndex, int PageSize, double Radius, string Zip)
        {
            Paged <JobWithDistance> pagedList = null;
            List <JobWithDistance>  list      = null;
            int totalCount = 0;

            LastColumn = 0;

            string procName = "[dbo].[Jobs_SearchPaginated_ByZip]";

            _data.ExecuteCmd(
                procName,
                delegate(SqlParameterCollection inputCollection)
            {
                inputCollection.AddWithValue("@PageIndex", PageIndex);
                inputCollection.AddWithValue("@PageSize", PageSize);
                inputCollection.AddWithValue("@Query", Query);
                inputCollection.AddWithValue("@Radius", Radius);
                inputCollection.AddWithValue("@Zip", Zip);
            },
                delegate(IDataReader reader, short set)
            {
                JobWithDistance job = MapJobWithDistance(reader);
                if (totalCount == 0)
                {
                    totalCount = reader.GetSafeInt32(LastColumn);
                }

                if (list == null)
                {
                    list = new List <JobWithDistance>();
                }
                list.Add(job);
            }
                );

            if (list != null)
            {
                pagedList = new Paged <JobWithDistance>(list, PageIndex, PageSize, totalCount);
            }

            return(pagedList);
        }
Exemple #2
0
        private static JobWithDistance MapJobWithDistance(IDataReader reader)
        {
            int             indexCounter = 0;
            JobWithDistance job          = new JobWithDistance();

            job.Id = reader.GetSafeInt32(indexCounter++);

            #region Created By
            job.CreatedBy           = new BaseUserProfile();
            job.CreatedBy.UserId    = reader.GetSafeInt32(indexCounter++);
            job.CreatedBy.FirstName = reader.GetSafeString(indexCounter++);
            job.CreatedBy.LastName  = reader.GetSafeString(indexCounter++);
            job.CreatedBy.Mi        = reader.GetSafeString(indexCounter++);
            job.CreatedBy.AvatarUrl = reader.GetSafeString(indexCounter++);
            #endregion

            #region Job Type
            job.JobType      = new TwoColumn();
            job.JobType.Id   = reader.GetSafeInt32(indexCounter++);
            job.JobType.Name = reader.GetSafeString(indexCounter++);
            #endregion

            #region Job Location
            job.JobLocation    = new Location();
            job.JobLocation.Id = reader.GetSafeInt32(indexCounter++);

            job.JobLocation.LocationType      = new TwoColumn();
            job.JobLocation.LocationType.Id   = reader.GetSafeInt32(indexCounter++);
            job.JobLocation.LocationType.Name = reader.GetSafeString(indexCounter++);

            job.JobLocation.LineOne = reader.GetSafeString(indexCounter++);
            job.JobLocation.LineTwo = reader.GetSafeString(indexCounter++);
            job.JobLocation.City    = reader.GetSafeString(indexCounter++);
            job.JobLocation.Zip     = reader.GetSafeString(indexCounter++);

            job.JobLocation.State      = new TwoColumn();
            job.JobLocation.State.Id   = reader.GetSafeInt32(indexCounter++);
            job.JobLocation.State.Name = reader.GetSafeString(indexCounter++);

            job.JobLocation.Latitude     = reader.GetSafeDouble(indexCounter++);
            job.JobLocation.Longitude    = reader.GetSafeDouble(indexCounter++);
            job.JobLocation.DateAdded    = reader.GetSafeDateTime(indexCounter++);
            job.JobLocation.DateModified = reader.GetSafeDateTime(indexCounter++);

            job.JobLocation.CreatedBy           = new BaseUserProfile();
            job.JobLocation.CreatedBy.UserId    = reader.GetSafeInt32(indexCounter++);
            job.JobLocation.CreatedBy.FirstName = reader.GetSafeString(indexCounter++);
            job.JobLocation.CreatedBy.LastName  = reader.GetSafeString(indexCounter++);
            #endregion

            job.Title        = reader.GetSafeString(indexCounter++);
            job.Description  = reader.GetSafeString(indexCounter++);
            job.Requirements = reader.GetSafeString(indexCounter++);
            job.IsActive     = reader.GetSafeBool(indexCounter++);
            job.DateCreated  = reader.GetSafeDateTime(indexCounter++);
            job.DateModified = reader.GetSafeDateTime(indexCounter++);
            job.Distance     = reader.GetSafeDouble(indexCounter++);

            if (LastColumn == 0)
            {
                LastColumn = indexCounter;
            }

            return(job);
        }