public IHttpActionResult GetParent(int id) { Parent parent = parentService.GetParent(id); if (parent == null) { return(NotFound()); } return(Ok(parent)); }
public async Task <IActionResult> Index() { var user = await _userManager.GetUserAsync(User); var isParent = await _userManager.IsInRoleAsync(user, "Parent"); var isStudent = await _userManager.IsInRoleAsync(user, "Student"); var isTeacher = await _userManager.IsInRoleAsync(user, "Teacher"); if (isStudent) { return(View(_gradeService.GetGrades(g => g.StudentId == user.Id))); } else if (isParent) { var students = _parentService.GetParent(s => s.Id == user.Id).Students; var grades = _gradeService.GetGrades( g => students.Any( s => s.Id == g.StudentId ) ); return(View(grades)); } else if (isTeacher) { return(RedirectToAction("AddGrade")); } else { return(View("Error")); } }