public async Task <ActionResult <List <StudentScore> > > scoreView([FromBody] ScoreViewRequest scoreView) { AccountSession session = await _repository.GetAccountBySessionToken(scoreView.Token); var account = await _repository.GetAccountById(session.AccountId); if (account.RoleId == (int)Roles.Student) { return(await _repository.GetScoresByStudentId(scoreView)); } if (account.RoleId == (int)Roles.Student) { return(await _repository.GetScores(scoreView)); } throw new Exception("NoPermission"); }
public async Task <List <StudentScore> > GetScoresByStudentId(ScoreViewRequest scoreView) { return(await _context.StudentScore.Where(s => s.StudentId == scoreView.AccountId).ToListAsync()); }
public async Task <List <StudentScore> > GetScores(ScoreViewRequest scoreView) { return(await _context.StudentScore.ToListAsync()); }