public async Task <IActionResult> GradeStudent(int id, string studentId, Grade grade) { if (studentId is null) { return(BadRequest()); } var userId = userManger.GetUserId(User); if (!await trainers.IsTrainer(id, userId)) { return(BadRequest()); } var success = await trainers.AddGrade(id, studentId, grade); if (!success) { return(BadRequest()); } return(RedirectToAction(nameof(Students), new { id })); }