Exemplo n.º 1
0
        public List <JobDto> GetJobsByEmployerID(int EmployerID)
        {
            JobAdvTypeObject jobAdvobj = new JobAdvTypeObject();
            var JobAdvTypes            = jobAdvobj.GetAllActiveAdvs();


            var query = from job in context.Jobs.AsEnumerable()
                        join adv in JobAdvTypes.AsEnumerable() on job.JobAdvTypeID equals adv.ID
                        where job.EmployerID == EmployerID
                        select new JobDto()
            {
                Description     = job.Description,
                EmployerID      = job.EmployerID,
                JobAdvType      = adv.Type,
                JobAdvTypeID    = job.JobAdvTypeID,
                JobID           = job.JobID,
                JobTypeID       = job.JobTypeID,
                LocationID      = job.LocationID,
                PostedDate      = job.PostedDate,
                SalaryFrom      = job.SalaryFrom,
                SalaryTo        = job.SalaryTo,
                Status          = (job.Status == "U" ? "Unpaid" : job.Status == "E" ? "Expired" : "Active"),
                Title           = job.Title,
                ValidFrom       = job.ValidFrom,
                ValidTo         = job.ValidTo,
                ValidationRange = "From " + job.ValidFrom.ToShortDateString() + " to " + job.ValidTo.ToShortDateString(),
                SalaryRange     = job.SalaryFrom + (String.IsNullOrEmpty(job.SalaryTo) ? "" : " _ " + job.SalaryTo)
            };

            return(query.ToList());
        }
Exemplo n.º 2
0
        public List <JobDto> GetJobByID(int JobID)
        {
            JobAdvTypeObject jobAdvobj = new JobAdvTypeObject();
            //    var JobAdvTypes = jobAdvobj.GetAllActiveAdvs();

            var query = from job in context.Jobs.AsEnumerable()
                        //                join adv in JobAdvTypes.AsEnumerable() on job.JobAdvTypeID equals adv.ID
                        join typ in context.JobTypes.AsEnumerable() on job.JobTypeID equals typ.JobTypeID
                        join loc in context.Locations.AsEnumerable() on job.LocationID equals loc.LocationID
                        join city in context.Cities.AsExpandable().AsEnumerable() on loc.CityID equals city.CityID
                        where job.JobID == JobID
                        select new JobDto
            {
                Description      = job.Description,
                ShortDescription = "",
                EmployerID       = job.EmployerID,
                JobAdvType       = city.CityName,
                JobAdvTypeID     = job.JobAdvTypeID,
                JobID            = job.JobID,
                JobTypeID        = job.JobTypeID,
                LocationID       = job.LocationID,
                PostedDate       = job.PostedDate,
                SalaryFrom       = job.SalaryFrom,
                SalaryTo         = job.SalaryTo,
                Status           = (job.Status == "U" ? "Unpaid" : job.Status == "E" ? "Expired" : "Active"),
                Title            = job.Title,
                ValidFrom        = job.ValidFrom,
                ValidTo          = job.ValidTo,
                ValidationRange  = "From " + job.ValidFrom.ToShortDateString() + " to " + job.ValidTo.ToShortDateString(),
                SalaryRange      = job.SalaryFrom + (String.IsNullOrEmpty(job.SalaryTo) ? "" : " _ " + job.SalaryTo),
                JobType          = typ.Description
            };

            return(query.ToList());
        }
Exemplo n.º 3
0
        public List <JobDto> GetJobs(string WhereClause)
        {
            string[] values   = null;
            string   Keywords = "";

            if (WhereClause != "")
            {
                var jobpredicate = PredicateBuilder.False <Job>();

                var citypredicate = PredicateBuilder.True <City>();

                JobAdvTypeObject jobAdvobj = new JobAdvTypeObject();
                var JobAdvTypes            = jobAdvobj.GetAdvs();

                string[] filters = WhereClause.Split('&');
                foreach (string filter in filters)
                {
                    string[] where = filter.Split('=');
                    switch (where[0])
                    {
                    case "DD":     //Description
                        Keywords = where[1];
                        values   = where[1].Split(';');

                        foreach (string value in values)
                        {
                            jobpredicate = jobpredicate.Or(p => p.Description.Contains(value) || p.Title.Contains(value));
                        }

                        jobpredicate = jobpredicate.And(p => p.Status == "A");
                        break;

                    case "LL":     //Locatin
                        values = where[1].Split(';');
                        if (values.Length > 0)
                        {
                            //http://zhino.blog.com/2012/02/15/in-clause-in-linq/
                            //JobAdvTypes = JobAdvTypes
                            //     .Where(e => values.Contains(e.ID.ToString()));
                            citypredicate = PredicateBuilder.False <City>();
                            foreach (string value in values)
                            {
                                citypredicate = citypredicate.Or(p => p.CityName.Contains(value));
                            }
                        }
                        break;
                    }
                }

                //http://www.albahari.com/nutshell/linqkit.aspx
                var query = from job in context.Jobs.AsExpandable().Where(jobpredicate).AsEnumerable()
                            join adv in JobAdvTypes.AsEnumerable()  on job.JobAdvTypeID equals adv.ID
                            join loc in context.Locations.AsEnumerable() on job.LocationID equals loc.LocationID
                            join city in context.Cities.AsExpandable().Where(citypredicate).AsEnumerable() on loc.CityID equals city.CityID

                            select new JobDto()
                {
                    Description      = job.Description,
                    ShortDescription = StripTagsRegex(job.Description),
                    EmployerID       = job.EmployerID,
                    JobAdvType       = city.CityName,
                    JobAdvTypeID     = job.JobAdvTypeID,
                    JobID            = job.JobID,
                    JobTypeID        = job.JobTypeID,
                    LocationID       = job.LocationID,
                    PostedDate       = job.PostedDate,
                    SalaryFrom       = job.SalaryFrom,
                    SalaryTo         = job.SalaryTo,
                    Status           = (job.Status == "U" ? "Unpaid" : job.Status == "E" ? "Expired" : "Active"),
                    Title            = job.Title,
                    ValidFrom        = job.ValidFrom,
                    ValidTo          = job.ValidTo,
                    ValidationRange  = "From " + job.ValidFrom.ToShortDateString() + " to " + job.ValidTo.ToShortDateString(),
                    SalaryRange      = job.SalaryFrom + (String.IsNullOrEmpty(job.SalaryTo) ? "" : " _ " + job.SalaryTo)
                };


                //Saving the selected keywords for providing online statistics later
                context.SetKeywordsPopularity(Keywords);

                return(query.ToList());
            }
            else
            {
                return(null);
            }
        }