public IActionResult AddToUnconfirmed(int sessionId, int id, User user)
        {
            if (user == null)
            {
                return(NotFound());
            }
            Session CurrentSession = _sessionRepository.GetById(sessionId);

            if (CurrentSession == null)
            {
                return(NotFound());
            }
            Member m = (Member)_userRepository.GetById(id);

            CurrentSession.AddToMembers(m);
            if (m.Formula.Name.Contains("en"))
            {
                _scoreRepository.Delete(_scoreRepository.GetByAmount(5, m.UserId));
            }
            else
            {
                _scoreRepository.Delete(_scoreRepository.GetByAmount(10, m.UserId));
            }
            _userRepository.SaveChanges();
            SessionViewModel svm = new SessionViewModel(CurrentSession);

            svm.SessionTeacher = (Teacher)_userRepository.GetByEmail(user.Email);
            svm.TrainingDay    = CurrentSession.TrainingDay;
            _sessionRepository.SaveChanges();
            return(RedirectToAction("Register", new { id = sessionId }));
        }
        public void Delete(Guid userId, Guid examId)
        {
            var ownerId = examService.IsRandom(examId) ? examRepository.GetRandomExam(examId).OwnerId : examRepository.Get(examId).OwnerId;

            if (ownerId == userId)
            {
                scoreRepository.Delete(userId, examId);
            }
        }
Beispiel #3
0
        public IActionResult DeleteScore(int scoreId)
        {
            var score  = _scoreRepository.GetScore(scoreId);
            var result = _resultRepository.GetResult(score.ResultId);
            var grade  = score.Grade * (-1);

            UpdateScores(grade, result);
            _scoreRepository.Delete(scoreId);

            return(RedirectToAction("CheckScore", new { resultId = result.ID }));
        }
Beispiel #4
0
 public int Delete(int id)
 {
     return(scoreRepository.Delete(id));
 }