public async Task <IActionResult> Put(PutParams putParams) { await mediator.Send( new StoreChainUpdateCommand(putParams.Id, putParams.Name)); return(Ok()); }
public async Task <IActionResult> Put(PutParams putParams) { await mediator.Send( new StoreUpdateCommand( putParams.Id, putParams.Name, putParams.Latitude, putParams.Longitude, putParams.Address)); return(Ok()); }
private static async Task <object> UpdateAdoptionStatus(string petId, string petType) { var putParams = new PutParams() { petid = petId, pettype = petType }; StringContent putData = new StringContent(JsonSerializer.Serialize(putParams)); return(await _httpClient.PutAsync(_configuration["updateadoptionstatusurl"], putData)); }
public async Task <ActionResult <Game> > Put(int id, [FromBody] PutParams putParams) { Game game = _gameController.FindGameById(id); Cellule cellule = putParams.Cellule; switch (game.GameState) { case GameState.WAITING: if (putParams.CustomBoatPlace) { _gameController.EditGameState(game, GameState.PLACE_BOAT); } else { _gameController.SetRandomCellToBoard(game.Id, "player1"); _gameController.EditGameState(game, GameState.PLAYER1_TURN); } break; case GameState.PLACE_BOAT: if (putParams.Cellules.Count == 0) { throw new Exception("Missing params : [List<Cellule> Cellules]"); } foreach (List <Cellule> boat in putParams.Cellules) { string identificator = $"boat-{boat.Count}-{Utils.RandomString(5)}"; foreach (Cellule boatCell in boat) { boatCell.BoatIdentificator = identificator; _celluleController.SafeEditCellule(boatCell); } } _gameController.EditGameState(game, GameState.PLAYER1_TURN); break; case GameState.PLAYER1_TURN: Cellule cell = _celluleController.FindCelluleById(cellule.Id); if (cell == null) { return(NoContent()); } _celluleController.HitCellule(cell); bool isWin = _gameController.IsGameWin(cellule.BoardId); _gameController.EditGameState(game, isWin ? GameState.PLAYER1_WIN : cell.IsBoat ? GameState.PLAYER1_HIT : GameState.PLAYER1_SINK); break; case GameState.PLAYER1_HIT: _gameController.EditGameState(game, GameState.PLAYER2_TURN); break; case GameState.PLAYER1_SINK: _gameController.EditGameState(game, GameState.PLAYER2_TURN); break; case GameState.PLAYER2_HIT: _gameController.EditGameState(game, GameState.PLAYER1_TURN); break; case GameState.PLAYER2_SINK: _gameController.EditGameState(game, GameState.PLAYER1_TURN); break; case GameState.PLAYER2_TURN: cell = _gameController.RunBoardIAPlay(game.Id); isWin = _gameController.IsGameWin(cell.BoardId); _gameController.EditGameState(game, isWin ? GameState.PLAYER2_WIN : cell.IsBoat ? GameState.PLAYER2_HIT : GameState.PLAYER2_SINK); break; } return(game); }