Example #1
0
        public PagedFindAJobList GetJobs(int id)
        {
            var page     = id;
            var allJobs  = this.jobRepository.GetAllQueryable.Count();
            var allPages = (int)Math.Ceiling(allJobs / (decimal)pageSize);
            var jobsData = this.jobRepository.GetAllQueryable.Select(x => new
            {
                x.Id,
                x.Title,
                x.Description,
                x.Tags
            }).OrderBy(x => x.Id)
                           .Skip((page - 1) * pageSize)
                           .Take(pageSize)
                           .ToList();


            var jobs = new List <CompanyJobsViewModel>();

            foreach (var job in jobsData)
            {
                var jobsViewModel = new CompanyJobsViewModel();
                jobsViewModel.Id          = job.Id;
                jobsViewModel.Title       = job.Title;
                jobsViewModel.Description = job.Description;
                jobsViewModel.Tags        = job.Tags;
                jobs.Add(jobsViewModel);
            }

            this.jobListModel.CurrentPage = page;
            this.jobListModel.TotalPages  = allPages;
            this.jobListModel.Jobs        = jobs;

            return(jobListModel);
        }
Example #2
0
        public IActionResult Jobs(int Id)
        {
            var model = new CompanyJobsViewModel
            {
                Jobs    = _jobService.GetAllByCompanyId(Id),
                Company = _companiesService.GetById(Id)
            };

            return(View(model));
        }