// GET: api/JobApply public List <JobApplyViewModel> GetJobApply() { var JobApplyList = db.JobApply.ToList(); List <JobApplyViewModel> JobApplyViewModelList = new List <JobApplyViewModel>(); foreach (var item in JobApplyList) { JobApplyViewModel JobApplyViewModel = new JobApplyViewModel(); Mapper.CreateMap <JobApply, JobApplyViewModel>(); JobApplyViewModel = Mapper.Map <JobApply, JobApplyViewModel>(item); JobApplyViewModel.JobName = item.Jobs.JobTitle; JobApplyViewModel.UserName = item.Users.UserName; JobApplyViewModel.CorporateName = item.Corporates.CorporateName; JobApplyViewModel.QuestionHeader = item.JobForm.QuestionHeader; JobApplyViewModel.UserAnswerName = item.UserAnswers.Answer; JobApplyViewModel.JobApplyStatusName = item.JobApplianceStatus.StatusName; JobApplyViewModelList.Add(JobApplyViewModel); } return(JobApplyViewModelList); }
public List <JobApplyViewModel> GetJobApplyById(int id) { var GetJobApplyList = db.JobApply.Where(w => w.UserId == id).ToList(); List <JobApplyViewModel> JobApplyViewModelList = new List <JobApplyViewModel>(); foreach (var item in GetJobApplyList) { JobApplyViewModel JobApplyViewModel = new JobApplyViewModel(); Mapper.CreateMap <JobApply, JobApplyViewModel>(); JobApplyViewModel = Mapper.Map <JobApply, JobApplyViewModel>(item); JobApplyViewModel.JobName = item.Jobs?.JobTitle; JobApplyViewModel.JobDescription = item.Jobs?.JobDescription; JobApplyViewModel.UserJobId = item.Jobs.Id; JobApplyViewModel.UserName = item.Users?.UserName; JobApplyViewModel.UserFirstName = item.Users?.FirstName; JobApplyViewModel.UserLastName = item.Users?.LastName; JobApplyViewModel.UserCountry = item.Users?.Country.CountryName; JobApplyViewModel.UserCity = item.Users?.City.CityName; JobApplyViewModel.UserAddress = item.Users?.Address; JobApplyViewModel.UserBirthdate = item.Users?.Birthdate.Value.ToString("MM/dd/yyyy"); JobApplyViewModel.UserEmail = item.Users?.Email; JobApplyViewModel.UserMobilenumber = item.Users?.Mobilenumber; JobApplyViewModel.CorporateName = item.Corporates?.CorporateName; JobApplyViewModel.QuestionHeader = item.JobForm?.QuestionHeader; JobApplyViewModel.UserAnswerName = item.UserAnswers?.Answer; JobApplyViewModel.JobApplyStatusName = item.JobApplianceStatus?.StatusName; JobApplyViewModelList.Add(JobApplyViewModel); } return(JobApplyViewModelList); }
public async Task <IActionResult> MessagesByPost(int postId) { ApplicationUser user = await this.userManager.GetUserAsync(this.User); JobApplyViewModel viewModel = this.jobPostsService.GetById <JobApplyViewModel>(postId); if (viewModel == null || viewModel.EmployerId != user.EmployerId) { return(this.NotFound()); } return(this.View(viewModel)); }
public IHttpActionResult PostJobApply(JobApplyViewModel jobApplyViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } JobApply JobApply = new JobApply(); Mapper.CreateMap <JobApplyViewModel, JobApply>(); JobApply = Mapper.Map <JobApplyViewModel, JobApply>(jobApplyViewModel); db.JobApply.Add(JobApply); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = jobApplyViewModel.Id }, jobApplyViewModel)); }
public async Task <IActionResult> DeleteMessage(int id) { CvMessage cvmessage = this.cvmessageService.GetMessage(id); if (cvmessage == null) { return(this.NotFound()); } ApplicationUser user = await this.userManager.GetUserAsync(this.User); JobApplyViewModel viewModel = this.jobPostsService.GetById <JobApplyViewModel>(cvmessage.JobPostId); if (viewModel == null || viewModel.EmployerId != user.EmployerId) { return(this.NotFound()); } await this.cvmessageService.DeleteAsync(cvmessage); return(this.Redirect($"/Management/Dashboard/Messages?postId={cvmessage.JobPostId}")); }
public IHttpActionResult PutJobApply(int id, JobApplyViewModel jobApplyViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != jobApplyViewModel.Id) { return(BadRequest()); } JobApply JobApply = new JobApply(); Mapper.CreateMap <JobApplyViewModel, JobApply>(); JobApply = Mapper.Map <JobApplyViewModel, JobApply>(jobApplyViewModel); db.Entry(JobApply).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JobApplyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> JobDetailsAsync(JobApplyViewModel model) { try { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); var jobseeker = _jobSeekerRepository.GetJobSeekerByUserId(user.Id); var jobcount = _IJobsApplyRepository.JobAppliedCount(user); if (jobcount >= model.MaxJobAllowed) { TempData["error"] = "You have already applied for max allowed jobs for today, Please try again tommorow"; return(View("JobApplyResult")); } if (_IJobsApplyRepository.IsAlreadyApplied(user.Id, model.JobID)) { RedirectToAction("AlreadyApplied"); } JobApply jobapply = new JobApply(); jobapply.JobID = model.JobID; jobapply.UserID = user.Id; jobapply.JobSeeker = jobseeker; jobapply.ApplyDate = DateTime.Now; if (model.IsExperience != null) { jobapply.IsExperience = Convert.ToBoolean(model.IsExperience); } if (!String.IsNullOrEmpty(model.ExpYear) && !String.IsNullOrEmpty(model.ExpMonth)) { jobapply.Experience = Convert.ToString(model.ExpYear + " years " + model.ExpMonth + " months "); } _IJobsApplyRepository.Create(jobapply); List <EmailAddress> emailAddress = new List <EmailAddress>() { new EmailAddress() { Name = user.UserName, Address = user.Email } //, //new EmailAddress() //{ // Name = "AJJ Job Apply Alert", // Address = "*****@*****.**" //}, }; var job = _IJobsRepository.GetJobsById(jobapply.JobID); var jobSeeker = _jobSeekerRepository.Find(x => x.ApplicationUserId == user.Id).FirstOrDefault(); string jobtitle = job.JobTitle; string companyName = job.CompanyName; string candidateName = jobSeeker.LastName + " " + jobSeeker.FirstName; TempData["warning"] = $"You can apply total {model.MaxJobAllowed} jobs in one day, Today your have already applied for {jobcount + 1} job"; _emailService.SendEmailAsync2(emailAddress, "jobapply", jobtitle, companyName, candidateName); } return(RedirectToAction("JobSavedSuccess")); } //catch (Microsoft.EntityFrameworkCore.DbUpdateException ex) //{ // return RedirectToAction("AlreadyApplied"); //} catch (Exception ex) { ViewData["error"] = "Some Error while apply for job"; } return(View("JobDetails/" + model.JobID)); }