public static Interview DTOToInterview(InterviewDTO interviewDTO) => new Interview() { ApplicationId = interviewDTO.ApplicationId, RecruiterId = interviewDTO.RecruiterId, Date = interviewDTO.Date };
public async Task <ActionResult> Add(InterviewDTO interviewDTO) { interviewDTO.SalesPerson = await _salesPersonService.GetByNameAndEmailAsync(interviewDTO.SalesPerson); var company = await _companyService.GetByNameAsync(interviewDTO.Company.Name); if (company == null) { company = await _companyService.AddAsync(interviewDTO.Company, true); } interviewDTO.Company = company; var interviewer = await _interviewerService.GetByNameAndEmailAsync(interviewDTO.Interviewer); if (interviewer == null) { interviewDTO.Interviewer.Company = company; interviewer = await _interviewerService.AddAsync(interviewDTO.Interviewer); } interviewDTO.Interviewer = interviewer; var interview = await _interviewService.AddAsync(interviewDTO); foreach (var fairId in interviewDTO.FairIds) { await _interviewFairService.AddAsync(new InterviewFairDTO { Name = "GörüşmeKaydıFuar" + fairId, Interview = interview, Company = interviewDTO.Company, Fair = _fairService.Get(Guid.Parse(fairId)) }); } return(Ok()); }
public async Task <IActionResult> Create(InterviewDTO interviewDto) { var interview = _mapper.Map <Interview>(interviewDto); await _repo.Create(interview); if (await _repo.SaveAll()) { return(CreatedAtRoute("CreateInterview", new { id = interview.Id }, interview)); } return(BadRequest("creation unsuccessful")); }
public async Task <string> UpdateAsync(InterviewDTO interviewDTO) { HttpRequestMessage requestMessage = new HttpRequestMessage() { RequestUri = new Uri("http://localhost:57892/api/Interview/Update"), Method = HttpMethod.Post, Content = HttpRequestExtensions.ContentAsByteJson(interviewDTO), }; var response = await _httpClient.SendAsync(requestMessage); if (response.StatusCode == HttpStatusCode.OK) { return(await Task.FromResult("Görüşme Güncellendi.")); } return(await Task.FromResult("Görüşme Güncellenemedi.")); }
public async Task <IActionResult> Update(InterviewDTO interviewDto) { var interview = _mapper.Map <Interview>(interviewDto); var thisInterview = await _repo.Get(interview.Id); if (thisInterview == null) { return(BadRequest("Interview not found")); } if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Update unsuccessful")); }
public async Task <ActionResult <InterviewDTO> > PostInterview(InterviewDTO interviewDTO) { User user = await userManager.FindByIdAsync(User.Identity.Name); Interview interview = null; if (await userManager.IsInRoleAsync(user, UserRoles.Admin)) { // Admin can create interview or any recruiter on any job interview = DTOToInterview(interviewDTO); } else { // Recruiter can only create interviews for themselves and for their own jobs var query = from job in _context.JobPosts join application in _context.Applications on job.JobPostId equals application.JobId join recruiter in _context.Recruiters on user.Id equals recruiter.UserId where application.ApplicationId == interviewDTO.ApplicationId && job.CompanyId == recruiter.CompanyId select job; JobPost jobPost = await query.FirstOrDefaultAsync(); if (jobPost == null) { return(Unauthorized("Cannot create an interview for a job that you either do not own, or does not exist")); } interview = DTOToInterview(interviewDTO); interview.RecruiterId = user.Id; } _context.Interviews.Add(interview); await _context.SaveChangesAsync(); return(CreatedAtAction("PostInterview", new { interview.ApplicationId }, InterviewToDTO(interview))); }
public async Task <InterviewDTO> Update(InterviewDTO interviewDTO) { return(await _interviewService.UpdateAsync(interviewDTO)); }
public async Task <ActionResult <InterviewDTO> > PatchInterview(long applicationId, InterviewDTO interviewDTO) { if (applicationId != interviewDTO.ApplicationId) { return(BadRequest("applicationId in query params does not match applicationId in body")); } User user = await userManager.FindByIdAsync(User.Identity.Name); Interview interview = null; if (await userManager.IsInRoleAsync(user, UserRoles.Admin)) { // Admin can update interview or any recruiter on any job interview = DTOToInterview(interviewDTO); } else { // Recruiter can only update interviews for themselves and for their own jobs var query = from job in _context.JobPosts join application in _context.Applications on job.JobPostId equals application.JobId join recruiter in _context.Recruiters on user.Id equals recruiter.UserId where application.ApplicationId == interviewDTO.ApplicationId && job.CompanyId == recruiter.CompanyId select job; JobPost jobPost = await query.FirstOrDefaultAsync(); if (jobPost == null) { return(Unauthorized("Cannot update an interview for a job that you either do not own, or does not exist")); } interview = DTOToInterview(interviewDTO); interview.RecruiterId = user.Id; } if (interview == null) { return(NotFound()); } _context.Interviews.Update(interview); await _context.SaveChangesAsync(); return(Ok(InterviewToDTO(interview))); }
public async Task <ActionResult> AddInterview(InterviewDTO interviewDTO) { await _interviewClient.AddInterview(interviewDTO); return(RedirectToAction("Index")); }
public async Task <ActionResult> InterviewUpdate(InterviewDTO interviewDTO) { var result = await _interviewClient.UpdateAsync(interviewDTO); return(RedirectToAction("Index")); }