예제 #1
0
 public ActionResult ListSortedJobs(JobFilterViewModel filter)
 {
     if (ModelState.IsValid)
     {
         return(Ok(_jobService.Filter(filter)));
     }
     return(null);
 }
예제 #2
0
        public async Task <JobViewModel> GetWeekTask(JobFilterViewModel model)
        {
            IJob task = await jobService.GetJobById(model.JobId);

            var jobAssignId      = Guid.Empty;
            var existingAssignId = model.DayAssignId.HasValue ? model.DayAssignId.Value : Guid.Empty;
            var dayAssign        = dayAssignProvider.Get(existingAssignId);

            if (dayAssign != null)
            {
                JobAssign jobAssign = jobAssignProvider.GetById(dayAssign.JobAssignId);
                task.Assigns.Add(jobAssign);
                jobAssignId = dayAssign.JobAssignId;
                task.DayAssigns.Add(dayAssign);
            }
            else
            {
                jobAssignId = jobAssignProvider.GetAssignByJobIdAndDepartmentId(model.JobId, model.HousingDepartmentId).Id;
                //Create new dayAssign and set status "Assigned"
                var newDayAssignModel = new NewDayAssignViewModel
                {
                    JobId          = model.JobId,
                    DepartmentId   = model.HousingDepartmentId,
                    JobAssignId    = jobAssignId,
                    CurrentWeekDay = model.CurrentWeekDay,
                    WeekNumber     = model.WeekNumber,
                    Date           = model.Date
                };

                var createResult = await dayAssignService.CreateDayAssignWithEstimate(newDayAssignModel);

                if (createResult != Guid.Empty)
                {
                    var newDayAssign = dayAssignProvider.Get(createResult);
                    await jobStatusService.Assigned(createResult, newDayAssign.StatusId);

                    task.DayAssigns.Add(newDayAssign);
                }
            }

            return(new JobViewModel {
                Job = task, JobAssignId = jobAssignId
            });
        }
        public async Task <IViewComponentResult> InvokeAsync(JobFilterViewModel jobFilterViewModel, CancellationToken cancellationToken)
        {
            if (jobFilterViewModel.FilterSet == null)
            {
                var jobStatuses = new List <JobStatuses>();

                var user = await _authService.GetCurrentUser(HttpContext, cancellationToken);

                if (jobFilterViewModel.JobFilterRequest.HighlightJobId.HasValue)
                {
                    int jobId = jobFilterViewModel.JobFilterRequest.HighlightJobId.Value;
                    var job   = await _requestService.GetJobSummaryAsync(jobId, cancellationToken);

                    if (job != null)
                    {
                        jobStatuses.Add(job.JobStatus);
                    }
                }

                if (jobFilterViewModel.JobFilterRequest.HighlightRequestId.HasValue)
                {
                    int requestId = jobFilterViewModel.JobFilterRequest.HighlightRequestId.Value;
                    var request   = await _requestService.GetRequestSummaryAsync(requestId, cancellationToken);

                    if (request != null)
                    {
                        jobStatuses = request.JobStatusDictionary().Keys.ToList();
                    }
                }

                jobFilterViewModel.FilterSet = await _filterService.GetDefaultSortAndFilterSet(jobFilterViewModel.JobFilterRequest.JobSet, jobFilterViewModel.JobFilterRequest.GroupId, jobStatuses, user, cancellationToken);
            }

            jobFilterViewModel.JobFilterRequest.UpdateFromFilterSet(jobFilterViewModel.FilterSet);

            return(View("JobFilterPanel", jobFilterViewModel));
        }
예제 #4
0
        public IEnumerable <JobViewModel> Filter(JobFilterViewModel filter)
        {
            IEnumerable <Job> result = Database.Jobs.GetAll().Include(c => c.Project).ThenInclude(project => project.Company).ThenInclude(company => company.CompanyAppUsers).Include(job => job.JobSkills).ThenInclude(jobSkill => jobSkill.Skill);

            // sort by conformity
            if (filter.IsMostRelevant && filter.Skills != null)
            {
                result = SortByMostRelevant(result.ToList(), filter.Skills).ToList();
            }
            else
            {
                result = SortByMostRecent(result);
            }

            // sort by name
            if (!string.IsNullOrEmpty(filter.CompanyName))
            {
                result = result.Where(job => job.Project.Company.Name.Trim().ToLowerInvariant() == filter.CompanyName.Trim().ToLowerInvariant());
            }

            // sort by location
            if (!string.IsNullOrEmpty(filter.Location))
            {
                result = result.Where(job => !String.IsNullOrEmpty(job.Location) && job.Location.Trim().ToLowerInvariant().Contains(filter.Location.Trim().ToLowerInvariant()));
            }

            // sort by job types
            if (filter.JobTypes != null && filter.JobTypes.Count() != 0)
            {
                result = result.Where(job => filter.JobTypes.Contains(job.JobType.GetDescription(), StringComparer.InvariantCultureIgnoreCase));
            }

            // sort by skills
            if (filter.Skills != null && filter.Skills.Count() != 0)
            {
                result = result.Where(job => job.JobSkills.Any(jobSkill => jobSkill.Job == job && filter.Skills.Any(skill => skill.Contains(jobSkill.Skill.Name, StringComparison.InvariantCultureIgnoreCase))));
            }

            // sort by experience
            if (filter.Experience != null && filter.Experience.Count() != 0)
            {
                result = result.Where(job => filter.Experience.Contains(job.Experience.GetDescription(), StringComparer.InvariantCultureIgnoreCase));
            }

            // sort by industry
            if (!string.IsNullOrEmpty(filter.Industry))
            {
                result = result.Where(job => job.Industry.GetDescription().Trim().ToLowerInvariant() == filter.Industry.Trim().ToLowerInvariant());
            }

            // sort by certificates
            if (filter.Certificates != null && filter.Certificates.Count() != 0)
            {
                //result = result.Where(job => job.Certificates.Any(jobCertificate => jobCertificate.Job == job && filter.Certificates.Contains(jobCertificate.Certificate.Name, StringComparer.InvariantCultureIgnoreCase)));
            }

            // sort by company size
            if (filter.MinCompanySize != filter.MaxCompanySize)
            {
                result = result.Where(job =>
                                      job.Project.Company.CompanyAppUsers.Count(companyAppUser => companyAppUser.CompanyId == job.Project.Company.Id) > filter.MinCompanySize &&
                                      job.Project.Company.CompanyAppUsers.Count(companyAppUser => companyAppUser.CompanyId == job.Project.Company.Id) < filter.MaxCompanySize);
            }

            return(Mapping.Map <IEnumerable <Job>, IEnumerable <JobViewModel> >(result));
        }