public async Task <IActionResult> AddStudentToClass(StudentClassesViewModels input) { var student = await _student.GetStudentByIdAsync(input.StudentId); var studentClass = await _student.getClassByNameAsync(input.ChoosenClass.ToString()); await _manager.AddStudentToClassAsync(student, studentClass); return(RedirectToAction("Index", "Home", null)); }
public async Task <IActionResult> AddStudentToClass(int id) { var student = await _student.GetStudentByIdAsync(id); var classes = _student.GetAllClasses().Select(c => new SelectListItem { Value = c.ClassName, Text = c.ClassName }); var model = new StudentClassesViewModels() { FirstName = student.FirstName, LastName = student.LastName, Classes = classes, StudentId = student.Id }; return(View(model)); }