public async Task CreateInPerson(CreateInPersonInterviewBindingModel model) { var firstInterviewer = this.DbContext.Users.Find(model.FirstInterviewerId); var secondInterviewer = this.DbContext.Users.Find(model.SecondInterviewerId); var interview = new Interview() { ApplicantId = model.ApplicantId, StartTime = model.StartTime, EndTime = model.EndTime, TestId = null, Interviewers = new List <InterviewInterviewer>() { new InterviewInterviewer() { InterviewerId = firstInterviewer.Id } } }; if (secondInterviewer != null) { interview.Interviewers .Add( new InterviewInterviewer() { InterviewerId = secondInterviewer.Id }); } await this.DbContext.Interviews.AddAsync(interview); await this.DbContext.SaveChangesAsync(); }
public async Task <IActionResult> CreateInPerson(CreateInPersonInterviewBindingModel model) { if (!ModelState.IsValid) { model.Applicants = this.applicants.GetApplicants(); model.Interviewers = await this.GetInterviewers(); return(View(model)); } await this.interviews.CreateInPerson(model); TempData.AddSuccessMessage(InterviewMessage); return(RedirectToAction(nameof(Index))); }