public ActionResult ApplyForJob(int id = -1) { ViewBag.JobsIdList = GetJobIds(); ViewBag.EmployerIdList = GetEmployerIds(); var candidate = _repositoryEndPointService.GetCandidateByEmailAddress(User.Identity.Name.ToLower()); if (candidate != null) { ViewBag.CandidateId = candidate.CandidateId; } else { ViewBag.CandidateId = -1; return(View("Failed")); } var job = _repositoryEndPointService.GetJobsById(id); if (job == null) { return(View("Failed")); } var mapper = AutoMapperConfig.Configure(); var jobViewModel = mapper.Map <Job, JobViewModel>(job); return(View(jobViewModel)); }