Пример #1
0
        public async Task <Score> ExecuteAsync(SetScoreCommand command, Score previousResult)
        {
            var currentSong = await _currentSongRepository.FirstOrDefault();

            if (currentSong == null)
            {
                return(null);
            }

            var actualScore = (await _scoreRepository.GetAll($"select * from c where c.judgeUserId = '{command.JudgeUserId}' and c.songId = '{command.SongId}'")).FirstOrDefault();

            if (actualScore != null)
            {
                actualScore.ScoreNumber = command.ScoreNumber;
                actualScore.ScoredAt    = DateTime.UtcNow;

                await _scoreRepository.Update(actualScore);

                return(actualScore);
            }

            var score = new Score()
            {
                Id           = Guid.NewGuid(),
                JudgeUserId  = command.JudgeUserId,
                ScoredAt     = DateTimeOffset.UtcNow,
                ScoreNumber  = command.ScoreNumber,
                SingerUserId = currentSong.AddedByUser,
                SongId       = currentSong.SongId
            };

            await _scoreRepository.Add(score);

            return(score);
        }
Пример #2
0
        public async Task <IActionResult> VoteUp(string name, int resultID)
        {
            var result = _resultRepository.GetResult(resultID);
            var user   = await userManager.FindByNameAsync(name);

            var score = new Score
            {
                ResultId = result.ID,
                Grade    = 1,
                UserId   = user.Id
            };

            _scoreRepository.Add(score);
            UpdateScores(1, result);

            return(RedirectToAction("Result", new { id = result.PhotoId, search = result.SearchId }));
        }
Пример #3
0
        public async Task Add(Guid songId, int score)
        {
            var user = this.userService.Get();

            if (user == null)
            {
                throw new Exception("Invalid user");
            }
            await scoreRepository.Add(new Score { SongId = songId, JudgeUserId = user.Id, ScoreNumber = score });
        }
        public ActionResult <Score> PostScore(ScoreDTO score)
        {
            Score scoreToCreate = new Score()
            {
                QuizId = score.quizId, Nicknaam = score.Nicknaam, Punten = score.Punten, Tijd = score.Tijd
            };

            _scoreRepository.Add(scoreToCreate);
            _scoreRepository.SaveChanges();
            return(CreatedAtAction(nameof(GetScore), new { id = scoreToCreate.Id }, scoreToCreate));
        }
Пример #5
0
        public void AddCustomer(CustomerDto customerDto)
        {
            customerDto.Score = GetScore(customerDto.Name);

            Customer customer = new Customer
            {
                Id    = customerDto.Id,
                Score = customerDto.Score
            };

            customer.Name = EncodeName(customerDto.Name);

            scoreRepository.Add(customer);
        }
Пример #6
0
        public void IncrementScore(int quantity)
        {
            var actualScore = _scoreRepository.Add(quantity);

            ScoreChanged(actualScore);
            var maxScore = _maxScoreRepository.Find();

            if (actualScore > maxScore)
            {
                _maxScoreRepository.Update(actualScore);
                MaxScoreReached(actualScore);
                _leaderboardScoreService.UpdateLeaderBoard(actualScore);
            }
        }
        public ActionResult <List <RankResultViewModel> > Add([FromBody] UserScoreViewModel model)
        {
            var result = new List <RankResultViewModel>();

            if (model.IsFeedback)
            {
                model.UserId = _userRepository.GetUserInformationByEmail(model.Email).Id;
            }
            else
            {
                model.UserId = GetUser().Id;
            }


            if (model.UserId != 0)
            {
                _scoreRepository.Add(new UserScore
                {
                    UserId            = model.UserId,
                    GuestCode         = model.GuestCode,
                    GameName          = model.GameName,
                    BookId            = model.BookId,
                    ChapterId         = model.ChapterId,
                    AddedDate         = model.AddedDate,
                    Score             = model.Score,
                    FeedbackUniqueKey = model.FeedbackUniqueKey,
                    BaseLanguageId    = model.BaseLanguageId,
                    TargetLanguageId  = model.TargetLanguageId
                }, model.UserId);

                _scoreRepository.IncreaseScore(model.Score, model.UserId);
            }

            result.AddRange(_scoreRepository.GetTopRanks(new UserScore
            {
                GameName         = model.GameName,
                BookId           = model.BookId,
                ChapterId        = model.ChapterId,
                Count            = model.Count,
                BaseLanguageId   = model.BaseLanguageId,
                TargetLanguageId = model.TargetLanguageId
            }).Select(x => new RankResultViewModel
            {
                Score       = x.Score,
                DisplayName = x.DisplayName,
                Email       = x.Email
            }));
            return(Ok(result.Take(5).ToList()));
        }
        public ActionResult <Score> PostScore(ScoreDTO scoreDTO)
        {
            if (_scoreRepository.GetByImageIdAndVoter(scoreDTO.IdSubmittedImage, scoreDTO.Voter) != null)
            {
                return(BadRequest("You already voted"));
            }
            if (_submittedImageRepository.GetById(scoreDTO.IdSubmittedImage).Creator == scoreDTO.Voter)
            {
                return(BadRequest("You can't vote on yourself!!!"));
            }
            var scoreToCreate = new Score(scoreDTO.IdSubmittedImage, scoreDTO.ImageScore, scoreDTO.Voter);

            //scoreToCreate.Id = _scoreRepository.GetNewID();
            _scoreRepository.Add(scoreToCreate);
            _scoreRepository.SaveChanges();
            return(CreatedAtAction(nameof(GetScoreById), new { id = scoreToCreate.Id }, scoreToCreate));
        }
Пример #9
0
 public Score Add(Score score)
 {
     return(_scoreRepository.Add(score));
 }
        public IActionResult Marks()
        {
            string[] useranswer  = new string[6];
            string[] answer      = new string[6];
            string[] question    = new string[6];
            string[] tempcorrect = new string[6];
            string[] tempuser    = new string[6];

            int marks = 0, i = 1;

            while (i < 6)
            {
                question[i]   = "question" + i;
                useranswer[i] = "useranswer" + i;
                answer[i]     = "answer" + i;
                i++;
            }
            i = 1;

            while (i < 6)
            {
                question[i]   = HttpContext.Request.Form[question[i]];
                useranswer[i] = HttpContext.Request.Form[useranswer[i]];
                answer[i]     = HttpContext.Request.Form[answer[i]];
                i++;
            }

            i = 1;
            while (i < 6)
            {
                if (useranswer[i] == answer[i])
                {
                    marks++;
                }
                else
                {
                    tempcorrect[i] = "Correct answer is: " + answer[i];
                    tempuser[i]    = "Your answer is: " + useranswer[i];
                }
                i++;
            }
            ViewBag.question    = question;
            ViewBag.tempcorrect = tempcorrect;
            ViewBag.tempuser    = tempuser;
            ViewBag.marks       = marks;

            Score  score = new Score();
            string subject, difficulty, username;

            subject          = HttpContext.Request.Form["subject"];
            difficulty       = HttpContext.Request.Form["difficulty"];
            username         = HttpContext.Request.Form["username"];
            score.Subject    = subject;
            score.Difficulty = difficulty;
            score.Mark       = marks;
            score.Username   = username;
            _ScoreRepository.Add(score);
            if (_ScoreRepository.SaveChanges())
            {
                Console.WriteLine("score added");
            }
            return(View());
        }