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); }
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); }
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}"); }
public EvaluationData AddData(EvaluationData newData) { ValidateData(newData); return(_evaluationDataController.Add(newData)); }
public EvaluationData Add(EvaluationData newData) { return(_evaluationDataController.Add(newData)); }