Ejemplo n.º 1
0
        public virtual async Task <ActionResult> ListAjax(ApplicantSearchRequest request)
        {
            var viewModel = await _applicantService.GetPagedListAsync(request);

            if (viewModel.Applicants == null || !viewModel.Applicants.Any())
            {
                return(Content("no-more-info"));
            }
            return(PartialView(MVC.Applicant.Views._ListAjax, viewModel));
        }
Ejemplo n.º 2
0
        public async Task <ApplicantListViewModel> GetPagedListAsync(ApplicantSearchRequest request)
        {
            var applicants =
                _applicants.Include(a => a.CreatedBy)
                .Include(a => a.ModifiedBy)
                .AsNoTracking()
                .AsQueryable();

            if (request.BirthCertificateNumber.HasValue())
            {
                applicants = applicants.Where(a => a.BirthCertificateNumber == request.BirthCertificateNumber).AsQueryable();
            }
            if (request.NationalCode.HasValue())
            {
                applicants = applicants.Where(a => a.NationalCode == request.NationalCode).AsQueryable();
            }
            if (request.FirstName.HasValue())
            {
                applicants = applicants.Where(a => a.FirstName.Contains(request.FirstName)).AsQueryable();
            }
            if (request.LastName.HasValue())
            {
                applicants = applicants.Where(a => a.LastName.Contains(request.LastName)).AsQueryable();
            }

            if (request.State.HasValue())
            {
                applicants = applicants.Where(a => a.BirthPlaceState == request.State).AsQueryable();
                if (request.City.HasValue())
                {
                    applicants = applicants.Where(a => a.BirthPlaceCity == request.City).AsQueryable();
                }
            }
            applicants = applicants.OrderBy($"{request.CurrentSort} {request.SortDirection}");

            var selectedApplicants = applicants.ProjectTo <ApplicantViewModel>(_mappingEngine);
            var resultsToSkip      = (request.PageIndex - 1) * request.PageSize;
            var query = await selectedApplicants
                        .Skip(() => resultsToSkip)
                        .Take(() => request.PageSize)
                        .ToListAsync();

            return(new ApplicantListViewModel {
                SearchRequest = request, Applicants = query
            });
        }
Ejemplo n.º 3
0
        public List <Model.Applicant> Get(ApplicantSearchRequest request)
        {
            var query = _context.Applicant.Include(x => x.ApplicationUser).ThenInclude(y => y.Country).Include(q => q.University).AsQueryable();

            //if (!string.IsNullOrWhiteSpace(request?.ImePrezime))
            //{
            //    query = query.Where(x => (x.ApplicationUser.Name + " " + x.ApplicationUser.Surname).ToLower().Contains(request.ImePrezime.ToLower()) ||
            //                              x.ApplicationUser.UserName.Contains(request.ImePrezime.ToLower()));
            //}

            //if (!string.IsNullOrWhiteSpace(request?.UserName))
            //{
            //    query = query.Where(x => x.ApplicationUser.UserName.ToLower().StartsWith(request.UserName));
            //}

            var list = query.ToList();

            return(_mapper.Map <List <Model.Applicant> >(list));
        }
Ejemplo n.º 4
0
 public ApplicantsViewModel(INavigation navigation, ApplicantSearchRequest request)
 {
     _search         = request;
     this.Navigation = navigation;
     InitCommand     = new Command(async() => await Init());
 }