public async Task <ActionResult> UpdateScore([FromBody] UpdateScoreRequest request) { if (request.Score < 0 || request.Score > 5) { return(BadRequest("Score is out of range")); } if (string.IsNullOrWhiteSpace(request.Player)) { return(BadRequest("Player must be provided")); } var command = new UpdateScoreCommand { Score = request.Score, Player = request.Player }; var result = await _mediator.Send(command); if (!result.Success) { if (result.ResponseCode == 404) { return(NotFound("Player not found")); } return(StatusCode(500, "Unable to fulfill request at this time")); } return(StatusCode(204)); }
public ScoreResponseModel Update(int id, ScoreRequestModel request) { UpdateScoreCommand command = new UpdateScoreCommand(id, request.Mark, request.StudentId, request.DisciplineId); Score score = updateScoreHandler.Handle(command); ScoreResponseModel response = scoresMapper.Map(score); return(response); }
public void Handle(Trigger trigger, IEntity entity) { if ((entity is Ball) == false) { return; } if (_updateScoreCommand == null) { var score = (ScoreTextBox)_entityManager.GetEntity(Constants.EntityIds.ScoreId); _updateScoreCommand = new UpdateScoreCommand(score) { IncrementPlayerScore = false }; } _commandManager.ClearQueue(); _commandManager.AddCommand(_updateScoreCommand); _commandManager.AddCommand(_newRoundCommand); //_commandManager.AddCommand(new FreezeCommand(1)); }
public Board() : base(ServiceProvider.Instance.Resolve <SpriteBatch>()) { Color = Color.Transparent; _updateScoreCommand = new UpdateScoreCommand((ScoreTextBox)_entityManager.GetEntity(Constants.EntityIds.ScoreId)); }