Пример #1
0
        public async Task <StudentScore> GiveScore(GiveScoreRequest giveScoreRequest, int providedById)
        {
            var scoreModel = new StudentScore()
            {
                StudentId    = giveScoreRequest.StudentId,
                SubjectId    = giveScoreRequest.SubjectId,
                Value        = giveScoreRequest.Score,
                ProvidedById = providedById
            };

            _context.Set <StudentScore>().Add(scoreModel);
            await _context.SaveChangesAsync();

            return(scoreModel);
        }
Пример #2
0
        public async Task <ActionResult <StudentScore> > GiveScore([FromBody] GiveScoreRequest giveScoreRequest)
        {
            var session = await _repository.GetAccountBySessionToken(giveScoreRequest.Token);

            var account = await _repository.GetAccountById(session.AccountId);

            if (account.RoleId != (int)Roles.Teacher)
            {
                throw new Exception("NoPermission");
            }

            var studentScore = await _repository.GiveScore(giveScoreRequest, session.Account.Id);

            return(studentScore);
        }