public async Task <IActionResult> Update(StudentManageViewModel model) { if (ModelState.IsValid) { try { await _studentsFacade.EditStudentAsync(model.Student); _logger.LogInformation("Updated student"); return(RedirectToAction(nameof(List))); } catch (BusinessLogicException ex) { _logger.LogError(ex.Message); var error = new ErrorViewModel { ErrorMessage = ex.Message, ReturnUrl = Request.GetReferer(), }; return(View("Error", error)); } } return(View(model)); }
public async Task <StudentManageViewModel> GetViewModel(int studentId) { var model = new StudentManageViewModel { Groups = await _groupApi.GetAll(), Student = await _studentApi.GetByIdAsync(studentId), }; return(model); }
public async Task <StudentManageViewModel> GetViewModel() { var model = new StudentManageViewModel { Groups = await _groupApi.GetAll(), Student = new Student(), }; return(model); }