public ActionResult Create(CreateInterviewRoundViewModel vm) { if (ModelState.IsValid) { var interviews = new List <int>(); foreach (var interviewer in vm.InterviewerIds.ToList()) { var newInterviewRound = new InterviewRound() { JobOpeningId = vm.JobOpeningId, CandidateId = vm.CandidateId, RoundId = vm.RoundId, InterviewerId = interviewer, ScheduledOn = vm.ScheduledOn, Status = InterviewStatus.Scheduled, Comments = vm.Comments }; _interviewRoundRepository.Create(newInterviewRound); _unitOfWork.Commit(); interviews.Add(newInterviewRound.Id); } foreach (var interviewId in interviews) { #if !DEBUG _emailComposerService.InterviewScheduled(interviewId); #endif } return(RedirectToAction("Index")); } ViewBag.CandidateId = new SelectList(_candidateRepository.GetAll(o => o.OrderByDescending(c => c.Id), "Person").Select(c => new { c.Id, Name = c.Person.Name + "- [" + c.Code + "]" }), "Id", "Name"); ViewBag.InterviewerId = new MultiSelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name", vm.InterviewerIds); ViewBag.JobOpeningId = new SelectList(_jobOpeningRepository.GetAll(), "Id", "Title"); ViewBag.RoundId = new SelectList(_roundRepository.GetAll(), "Id", "Title"); return(View(vm)); }
public JsonResult AddInterviewRound(CreateInterviewRoundViewModel vm) { try { var interviews = new List <int>(); foreach (var interviewer in vm.InterviewerIds.ToList()) { var newInterviewRound = new InterviewRound { JobOpeningId = vm.JobOpeningId, CandidateId = vm.CandidateId, RoundId = vm.RoundId, InterviewerId = interviewer, ScheduledOn = vm.ScheduledOn, Status = InterviewStatus.Scheduled, Comments = vm.Comments }; _interviewRoundRepository.Create(newInterviewRound); _unitOfWork.Commit(); interviews.Add(newInterviewRound.Id); } foreach (var interviewId in interviews) { #if !DEBUG _emailComposerService.InterviewScheduled(interviewId); #endif } return(Json(true)); } catch (Exception) { return(Json(false)); } }