Ejemplo n.º 1
0
        public ActionResult WordToTranslationResult(GameTranslationResult model)
        {
            int userId = int.Parse(User.FindFirst(TokenClaims.Id).Value);

            _gameService.SetWordProgress(userId, model);
            return(Ok());
        }
Ejemplo n.º 2
0
        public void SetWordProgress(int userId, GameTranslationResult model)
        {
            var word = _unitOfWork.WordUserRepository.Get(x => x.UserId == userId && x.WordId == model.WordId);

            if (word == null)
            {
                return;
            }
            word.LastUse = DateTime.UtcNow;
            word.Count   = model.IsSuccess ? word.Count + 1 : word.Count - 1;
            if (word.Count <= 0)
            {
                word.Count = 0;
            }
            _unitOfWork.WordUserRepository.Update(word);
            _unitOfWork.Commit();
        }