Esempio n. 1
0
        public async Task<Tuple<List<SearchJobSeekerApplicantRepone>, int, int>> SearchApplicant(SearchJobSeekerApplicantParams param)
        {
            using (AppDbContext context = new AppDbContext())
            {
                await GetCurrentUser(context);
                var query = context.Applicants.Include(x => x.Job).Include(x => x.Job.Employer).Include(x => x.Job.Location).Include(x => x.Job.Educations).Where(x => x.JobSeekerId == _userId && x.ApplicantStatus == param.ApplicantStatus).AsQueryable();

                int totalItems = await query.CountAsync();
                int totalPages = totalItems / param.PageSize;
                if (totalItems % param.PageSize > 0)
                {
                    totalPages++;
                }

                var result = await query.OrderByDescending(p => p.Job.JobName).Skip(param.PageIndex * param.PageSize).Take(param.PageSize).ToListAsync();
                List<SearchJobSeekerApplicantRepone> searchResult = new List<SearchJobSeekerApplicantRepone>();
                searchResult.AddRange(result.Select(x => new SearchJobSeekerApplicantRepone
                {
                    Id = x.Id,
                    JobId = x.JobId,
                    LocationId = x.Job.LocationId,
                    ApplicantStatus = x.ApplicantStatus,
                    CompanyName = x.Job.Employer.CompanyName,
                    Logo = x.Job.Employer.Logo,
                    Location = x.Job.Location,
                    JobType = x.Job.JobType,
                    JobName = x.Job.JobName,
                    MinSalary = x.Job.MinSalary,
                    MaxSalary = x.Job.MaxSalary,
                    EndDate = x.Job.EndDate,
                    StartDate = x.Job.StartDate,
                    UserId = x.JobSeekerId
                }));
                return new Tuple<List<SearchJobSeekerApplicantRepone>, int, int>(searchResult, totalPages, totalItems);
            }
        }
Esempio n. 2
0
        public async Task<ApiJsonResult> SearchApplicant(SearchJobSeekerApplicantParams param)
        {
            try
            {
                Guid userId = GetCurrentUserId();
                Tuple<List<SearchJobSeekerApplicantRepone>, int, int> result = await new JobManager(userId).SearchApplicant(param);

                return new ApiJsonPagingResult { Success = true, Data = result.Item1, TotalPages = result.Item2, TotalItems = result.Item3 };
            }
            catch (Exception ex)
            {
                return ProcessException(ex);
            }
        }