public JsonResult ColorRoundChoice(ColorRoundChoiceRequest request) { try { var response = _colorService.ColorRoundChoice(request); var model = _colorModelFactory.CreateColorRoundChoiceModel(response); return JsonResult.CreateSuccess(model); } catch (Exception ex) { return JsonResult.CreateFailure(ex.Message, ex); } }
public ColorRoundChoiceResponse ColorRoundChoice(ColorRoundChoiceRequest request) { var gameRound = _gameRoundRepository.Get(request.GameRoundId); var success = request.ProvidedAnswer == gameRound.Answer; if(!success) gameRound.PlayerHasFailedAnAttempt(); else { var score = _gameRoundScorerSpecification.DetermineScoreFromGameRound(gameRound); gameRound.SetScore(score); } using(var uow = _unitOfWorkFactory.BeginTransaction()) { _gameRoundRepository.Save(gameRound); uow.Commit(); } return new ColorRoundChoiceResponse { AttemptIsSuccessful = success }; }