public IActionResult Pass_InterviewScheme_Question(InterviewSchemeVM model) { _interviewScheme = new InterviewScheme(); _nationality = new Nationality(); _studyField = new StudyField(); model.Question.InterviewSchemeId = model.Id; var countquestions = _interviewScheme.GetQuestions(model.Id); if (countquestions.Count == 0) { model.Question.Order = 1; } else { countquestions = countquestions.OrderBy(x => x.Order).ToList(); var last = countquestions.LastOrDefault(); model.Question.Order = last.Order + 1; } _interviewScheme.AddQuestionToInterview(model.Question); var nationalities = _nationality.GetAllNationalities(); var studyfields = _studyField.GetAllStudyFields(); foreach (var country in nationalities) { model.Countries.Add(new SelectListItem() { Text = country.Name, Value = country.Id.ToString() }); } foreach (var study in studyfields) { model.Studyfields.Add(new SelectListItem() { Text = study.FieldName, Value = study.Id.ToString() }); } var questions = _interviewScheme.GetQuestions(model.Id); foreach (var quest in questions) { model.Questions.Add(new QuestionVM() { Id = quest.Id, Order = quest.Order, Answer = quest.Answer, InterviewSchemeId = quest.InterviewSchemeId, Quest = quest.Quest }); } model.Questions = model.Questions.OrderBy(x => x.Order).ToList(); return(View("../Administration/CreateQuestionToInterview", model)); }
public IActionResult Pass_new_Question(InterviewSchemeVM model) { _interviewScheme = new InterviewScheme(); model.Question.InterviewSchemeId = model.Id; var countquestions = _interviewScheme.GetQuestions(model.Id); if (countquestions.Count == 0) { model.Question.Order = 1; } else { countquestions = countquestions.OrderBy(x => x.Order).ToList(); var last = countquestions.LastOrDefault(); model.Question.Order = last.Order + 1; } _interviewScheme.AddQuestionToInterview(model.Question); return(RedirectToAction("Get_Specific_Interview", new { id = model.Id })); }