Exemple #1
0
        public PartialViewResult Offers(int countryID, double minSkill, double maxSkill, double minSalary, double maxSalary, bool?sameRegion, JobOfferTypeEnum offerType, WorkTypeEnum workTypeID, PagingParam pagingParam)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var offers = jobOfferRepository.Where(o => o.CountryID == countryID);

            if (offerType != JobOfferTypeEnum.Both)
            {
                offers = offers.Where(o => o.TypeID == (int)offerType);
            }
            if (workTypeID != WorkTypeEnum.Any)
            {
                offers = offers.Where(o => o.Company.WorkTypeID == (int)workTypeID);
            }
            //if (minSkill.HasValue)
            offers = offers.Where(o => o.MinSkill >= (decimal)minSkill);
            // if (maxSkill.HasValue)
            offers = offers.Where(o => o.MinSkill <= (decimal)maxSkill);
            //if (minSalary.HasValue)
            offers = offers.Where(o => o.NormalJobOffer.Salary >= (decimal)minSalary || o.ContractJobOffer.MinSalary >= (decimal)minSalary);
            //if(maxSalary.HasValue)
            offers = offers.Where(o => o.NormalJobOffer.Salary <= (decimal)maxSalary || o.ContractJobOffer.MinSalary <= (decimal)maxSalary);

            if (sameRegion == true)
            {
                int?regionID = SessionHelper.CurrentEntity.GetCurrentRegion()?.ID;
                offers = offers.Where(o => o.Company.RegionID == regionID);
            }


            JobOffersDOMSelector selector = new JobOffersDOMSelector();

            IList <JobOfferDOM> processed = offers
                                            .Apply(selector)
                                            .OrderByDescending(o => o.NormalSalary)
                                            .Apply(pagingParam)
                                            .ToList();

            var vm = new JobMarketOfferListViewModel(processed, countryID, (int)workTypeID, (int)offerType, minSalary, maxSalary, minSkill, maxSkill,
                                                     includeRegionInformation: sameRegion != true, pagingParam: pagingParam);

            return(PartialView(vm));
        }