// GET: Jobs
        // Include LINQ query to allow search
        public async Task <IActionResult> Index(string jobTitleString, string jobLocation, string companyString)
        {
            IQueryable <string> locationQuery = from j in _context.Job
                                                orderby j.Location
                                                select j.Location;

            var jobs = from j in _context.Job
                       select j;

            if (!String.IsNullOrEmpty(jobTitleString))
            {
                jobs = jobs.Where(j => j.JobTitle.Contains(jobTitleString));
            }

            if (!String.IsNullOrEmpty(jobLocation))
            {
                jobs = jobs.Where(j => j.Location == jobLocation);
            }

            if (!String.IsNullOrEmpty(companyString))
            {
                jobs = jobs.Where(j => j.Company.Contains(companyString));
            }

            var jobLocationVM = new JobLocationViewModel();

            jobLocationVM.locations = new SelectList(await locationQuery.Distinct().ToListAsync());
            jobLocationVM.jobs      = await jobs.ToListAsync();

            return(View(jobLocationVM));
        }
Esempio n. 2
0
        // GET: Job Count & Company Count for Non-Authenticated & Non-Admin Users

        public async Task <ActionResult> Index(string jobTitleString, string companyString, int selectedLocationId = 0, int JobID = 0)
        {
            // Include LINQ queries to allow filters
            var jobs = from j in context.Jobs
                       select j;

            // Var for counting number of companies used below in company count
            var companies = from c in context.Companies
                            select c;


            // Job title search form field
            if (!String.IsNullOrEmpty(jobTitleString))
            {
                jobs = jobs.Where(j => j.JobTitle.Contains(jobTitleString));
            }

            // company search form field
            if (!String.IsNullOrEmpty(companyString))
            {
                jobs = jobs.Where(j => j.CompanyCompanyName.Contains(companyString));
            }

            // grab a count of the number of jobs currently inside the jobs variable.
            int count = jobs.Count();

            // store it in viewbag for the View to display
            ViewBag.Counts = count;

            // Set JobID for indication whether Index action was called from Save action
            ViewBag.JobID = JobID;

            // Need for company count
            if (!String.IsNullOrEmpty(companyString))
            {
                companies = companies.Where(c => c.CompanyName.Contains(companyString));
            }
            // Grab a count of the number of companies inside the companies variable
            int companyCount = companies.Count();

            // store it in viewbag for the View to display
            ViewBag.companyCount = companyCount;

            //instantiate the view model and serve it to the view

            var jobLocationVM = new JobLocationViewModel();

            jobLocationVM.jobs = await jobs.ToListAsync();

            return(View(jobLocationVM));
        }
Esempio n. 3
0
        public async Task <JobLocationViewModel> GetLocationModel(string jobId, Guid?housingDepartmentId)
        {
            var job = await jobService.GetJobById(jobId);

            bool isGroupedJob = job.RelationGroupList.Any() && job.ParentId != null;
            var  model        = new JobLocationViewModel {
                IsGroupedJob = isGroupedJob
            };

            if (isGroupedJob)
            {
                bool isParent = job.ParentId == null;
                RelationGroupModel relationGroupModel = job.RelationGroupList.FirstOrDefault(x => x.HousingDepartmentId == housingDepartmentId);
                model.GroupedJobHousingDepartmentId = relationGroupModel?.HousingDepartmentId;
                IEnumerable <Guid> relationGroupIdList = job.RelationGroupList.Select(x => x.RelationGroupId);
                // housingDepartmentId can be null only for not grouped task, if admin during task creation doesn't choose any HD in department picker
                var groupedTasks = jobService.GetRelatedAddressListForHousingDepartment(relationGroupIdList, housingDepartmentId.Value, isParent);
                model.GroupedTasks = groupedTasks.Select(i => new IdValueModel <string, string> {
                    Id = i.Id, Value = i.Value
                });
                foreach (var task in groupedTasks)
                {
                    if (model.GroupedJobHousingDepartmentId.HasValue)
                    {
                        var addresses = new Dictionary <Guid, string>();
                        addresses.Add(model.GroupedJobHousingDepartmentId.Value, task.Value);
                        model.AddressList.Add(task.Id, addresses);
                    }
                }
            }
            else
            {
                var departments = jobService.GetAssignedDepartments(jobId);
                model.Departments = departments.Select(i => new IdValueModel <Guid, string> {
                    Id = i.Id, Value = i.DisplayName
                });
                model.AddressList.Add(jobId, job.AddressList.ToDictionary(k => k.HousingDepartmentId, v => v.Address));
            }

            return(model);
        }
Esempio n. 4
0
        // GET: Jobs

        public async Task <ActionResult> Index(string jobTitleString, string companyString, int selectedLocationId = 0, int JobID = 0)
        {
            // Include LINQ queries to allow filters
            var jobs = from j in context.Jobs
                       select j;

            // adding a var for counting number of companies used below in company count
            var companies = from c in context.Companies
                            select c;


            // Job title search form field
            if (!String.IsNullOrEmpty(jobTitleString))
            {
                jobs = jobs.Where(j => j.JobTitle.Contains(jobTitleString));
            }

            // company search form field
            if (!String.IsNullOrEmpty(companyString))
            {
                jobs = jobs.Where(j => j.CompanyCompanyName.Contains(companyString));
            }

            // grab a count of the number of jobs currently inside the jobs variable.
            int count = jobs.Count();

            // store it in viewbag for the View to display
            ViewBag.Counts = count;

            // Set JobID for indication whether Index action was called from Save action
            ViewBag.JobID = JobID;


            // Need for company count
            if (!String.IsNullOrEmpty(companyString))
            {
                companies = companies.Where(c => c.CompanyName.Contains(companyString));
            }
            // Grab a count of the number of companies inside the companies variable
            int companyCount = companies.Count();

            // store it in viewbag for the View to display
            ViewBag.companyCount = companyCount;

            // Create a list of jobIDs where the userID equals the current user
            // from the SavedJobs table. This is used to evaluate whether or not the
            // save button should be enabled or disabled in the job search results.
            if (User.Identity.GetUserId() != null)
            {
                var userID = Guid.Parse(User.Identity.GetUserId());
                IEnumerable <SavedJob> savedJobsView = context.SavedJobs.Where(s => s.UserID.Equals(userID));
                var usersSavedJobIDs = savedJobsView.Select(s => s.JobID).ToList();
                ViewBag.usersSavedJobIDs = usersSavedJobIDs;
            }


            //instantiate the view model and serve it to the view

            var jobLocationVM = new JobLocationViewModel();

            jobLocationVM.jobs = await jobs.ToListAsync();

            return(View(jobLocationVM));
        }