public ActionResult Index(InterviewSearchViewModel vm)
        {
            ViewBag.CandidateId   = new SelectList(_candidateRepository.GetAll(o => o.OrderByDescending(c => c.Id), "Person").Select(c => new { c.Id, Name = c.Person.Name + "- [" + c.Code + "]" }), "Id", "Name");
            ViewBag.InterviewerId = new SelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name");
            ViewBag.JobOpeningId  = new SelectList(_jobOpeningRepository.GetAll(), "Id", "Title");
            ViewBag.RoundId       = new SelectList(_roundRepository.GetAll(), "Id", "Title");

            Func <IQueryable <InterviewRound>, IQueryable <InterviewRound> > interviewRoundFilter = q =>
            {
                q = q.Include("Candidate.Person")
                    .Include("Interviewer.Person")
                    .Include(i => i.JobOpening)
                    .Include(i => i.Round);


                if (vm.JobId.HasValue)
                {
                    q = q.Where(r => r.JobOpeningId == vm.JobId.Value);
                }

                if (vm.CandidateId.HasValue)
                {
                    q = q.Where(r => r.CandidateId == vm.CandidateId.Value);
                }

                if (vm.InterviewerId.HasValue)
                {
                    q = q.Where(r => r.InterviewerId == vm.InterviewerId.Value);
                }

                if (vm.RoundId.HasValue)
                {
                    q = q.Where(r => r.RoundId == vm.RoundId.Value);
                }

                if (vm.Status.HasValue)
                {
                    q = q.Where(r => r.Status == vm.Status.Value);
                }

                return(q);
            };

            vm.Interviews = _interviewRoundRepository.SearchPage(interviewRoundFilter, o => o.OrderByDescending(c => c.ScheduledOn), vm.GetPageNo(), vm.PageSize);

            return(View(vm));
        }
Exemple #2
0
        public ActionResult Interviews(InterviewSearchViewModel vm)
        {
            return(RedirectIfNotLoggedIn(() =>
            {
                ViewBag.JobOpeningId = new SelectList(_jobOpeningRepository.GetAll(), "Id", "Title");
                ViewBag.RoundId = new SelectList(_roundRepository.GetAll(), "Id", "Title");
                var candidateId = int.Parse(Session[PortalKeyId].ToString());

                Func <IQueryable <InterviewRound>, IQueryable <InterviewRound> > interviewRoundFilter = q =>
                {
                    q = q.Include("Candidate.Person")
                        .Include(i => i.JobOpening)
                        .Include(i => i.Round);

                    q = q.Where(r => r.CandidateId == candidateId);

                    if (vm.JobId.HasValue)
                    {
                        q = q.Where(r => r.JobOpeningId == vm.JobId.Value);
                    }

                    if (vm.RoundId.HasValue)
                    {
                        q = q.Where(r => r.RoundId == vm.RoundId.Value);
                    }

                    if (vm.Status.HasValue)
                    {
                        q = q.Where(r => r.Status == vm.Status.Value);
                    }

                    return q;
                };

                vm.Interviews = _interviewRoundRepository.SearchPage(interviewRoundFilter, o => o.OrderByDescending(c => c.ScheduledOn), vm.GetPageNo(), vm.PageSize);
                return View(vm);
            }));
        }