コード例 #1
0
ファイル: ManagerController.cs プロジェクト: tom8b/SchoolSys
        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));
        }
コード例 #2
0
ファイル: ManagerController.cs プロジェクト: tom8b/SchoolSys
        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));
        }