Пример #1
0
        public async Task <string> SaveUserScore(IUserScore userScore)
        {
            if (userScore == null)
            {
                throw new ArgumentNullException(nameof(userScore));
            }

            string result = string.Empty;

            var newUserScore = new UserScore {
                UserId      = userScore.UserId,
                Score       = userScore.Score,
                CategoryId  = userScore.CategoryId,
                DateCreated = DateTime.UtcNow,
                DateTaken   = DateTime.Now,
            };

            try
            {
                await this._dataContext.UserScores.AddAsync(newUserScore);

                await this._dataContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                result = $"{e.Message}";
            }

            return(result);
        }
Пример #2
0
 public RankingApplicationService(IUserScore userScoreRepository)
 {
     this.ScoreRepository = userScoreRepository;
 }