public IActionResult ApplyJobPost(ApplyJobPostDTO model)
        {
            var user = _userService.GetUserById(model.UserId);

            if (string.IsNullOrEmpty(user.Id))
            {
                return(OK(StatusCodeType.USER_NOTFOUND, StatusMessage.USER_NOTFOUND, false));
            }
            if (user.ResponseCVDTO == null)
            {
                return(OK(StatusCodeType.CV_NOTFOUND, StatusMessage.CV_NOTFOUND, false));
            }
            var jobPost = _jobPostService.GetJobPostById(model.JobPostId);

            if (string.IsNullOrEmpty(jobPost.Id))
            {
                return(OK(StatusCodeType.JOBPOST_NOTFOUND, StatusMessage.JOBPOST_NOTFOUND, false));
            }

            var hasApplyUser = _jobPostService.AnyApplyUser(model);

            if (hasApplyUser)
            {
                return(OK(StatusCodeType.ALREADY_HASJOBPOST, StatusMessage.ALREADY_HASJOBPOST, false));
            }

            var response = _jobPostService.ApplyJobPost(model);

            if (string.IsNullOrEmpty(response.Id))
            {
                return(OK(StatusCodeType.HAS_EXCEPTION, StatusMessage.HAS_EXCEPTION, false));
            }

            return(OK(StatusCodeType.SUCCESS, StatusMessage.SUCCESS, response));
        }
Пример #2
0
        public ResponseJobPostDTO ApplyJobPost(ApplyJobPostDTO applyJobPostDTO)
        {
            var responseJobPostDTO = new ResponseJobPostDTO();

            if (applyJobPostDTO != null)
            {
                var jobPost = _jobPostRepository.GetFilter(x => x.Id == applyJobPostDTO.JobPostId);
                if (jobPost.Result != null)
                {
                    jobPost.Result.ApplyUsers.Add(applyJobPostDTO.UserId);
                    _jobPostRepository.Update(jobPost.Result);
                    responseJobPostDTO = _mapper.Map <ResponseJobPostDTO>(jobPost.Result);
                }
            }

            return(responseJobPostDTO);
        }
Пример #3
0
        public bool AnyApplyUser(ApplyJobPostDTO applyJobPostDTO)
        {
            if (applyJobPostDTO == null)
            {
                return(false);
            }

            var response = _jobPostRepository.GetFilter(x => x.Id == applyJobPostDTO.JobPostId &&
                                                        x.ApplyUsers.Contains(applyJobPostDTO.UserId));

            if (response.Result == null)
            {
                return(false);
            }

            return(true);
        }