Example #1
0
        public bool AddReward(int actorId, int gameId, Reward reward)
        {
            var evaluationDataController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, reward.EvaluationDataCategory);

            var evaluationData = new EvaluationData {
                Key                = reward.EvaluationDataKey,
                GameId             = gameId,
                ActorId            = actorId,
                Category           = reward.EvaluationDataCategory,
                EvaluationDataType = reward.EvaluationDataType,
                Value              = reward.Value
            };

            if (reward.EvaluationDataCategory == Common.EvaluationDataCategory.Resource)
            {
                var current = evaluationDataController.Get(gameId, actorId, new[] { reward.EvaluationDataKey });
                if (current.Any())
                {
                    evaluationData.Value = (long.Parse(reward.Value) + long.Parse(current.Single().Value)).ToString();

                    evaluationDataController.Update(evaluationData);
                }
                else
                {
                    evaluationDataController.Add(evaluationData);
                }
            }
            else
            {
                evaluationDataController.Add(evaluationData);
            }

            _logger.LogInformation($"Game Data: {evaluationData.Id} for ActorId: {actorId}, GameId: {gameId}, Reward: {reward.Id}");

            return(true);
        }
Example #2
0
        private void SetCompleted(Evaluation evaluation, int actorId)
        {
            var evaluationDataCoreController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, evaluation.EvaluationType.ToEvaluationDataCategory());

            var evaluationData = new EvaluationData {
                Category           = evaluation.EvaluationType.ToEvaluationDataCategory(),
                Key                = evaluation.Token,
                GameId             = evaluation.GameId,
                ActorId            = actorId,
                EvaluationDataType = EvaluationDataType.String,
                Value              = null
            };

            evaluationDataCoreController.Add(evaluationData);

            ProcessEvaluationRewards(evaluation, actorId);
        }
Example #3
0
        public void Create(EvaluationData data)
        {
            if (!EvaluationDataController.IsValid(data, out var failure))
            {
                throw new ArgumentException(failure);
            }

            var existingEntries = _evaluationDataController.Get(data.GameId, data.ActorId, new[] { data.Key });

            if (existingEntries.Any())
            {
                throw new DuplicateRecordException();
            }

            _evaluationDataController.Add(data);

            _logger.LogInformation($"{data.Id}");
        }
Example #4
0
        public EvaluationData AddData(EvaluationData newData)
        {
            ValidateData(newData);

            return(_evaluationDataController.Add(newData));
        }
 public EvaluationData Add(EvaluationData newData)
 {
     return(_evaluationDataController.Add(newData));
 }