public async Task <IHttpActionResult> Show(long gameId, PlayerChoose?playerChoose) { try { ShowGameView gameStatistics = new ShowGameView(); if (await _gameService.IsDoneGame(gameId)) { return(BadRequest("Game is done")); } if (playerChoose == null && await _gameService.IsNewGame(gameId)) { gameStatistics.ShowGameViewItems = await _gameService.DoFirstTwoRounds(gameId); return(Ok(gameStatistics)); } if (playerChoose == null && !(await _gameService.IsNewGame(gameId))) { gameStatistics.ShowGameViewItems = await _gameService.LoadGame(gameId); return(Ok(gameStatistics)); } gameStatistics.ShowGameViewItems = await _gameService.ContinuePlaying(gameId, (PlayerChoose)playerChoose); return(Ok(gameStatistics)); } catch (Exception exeption) { return(InternalServerError(exeption)); } }
public async Task <ActionResult> GameShow(long gameId) { try { ShowGameView gameStatistics = new ShowGameView(); gameStatistics.ShowGameViewItems = await _gameService.DoFirstTwoRounds(gameId); return(View(gameStatistics.ShowGameViewItems)); } catch (Exception exeption) { return(View("~/Views/Shared/Error.cshtml", exeption)); } }
public async Task <ActionResult> Game(long gameId, PlayerChoose number) { try { ShowGameView gameStatistics = new ShowGameView(); gameStatistics.ShowGameViewItems = await _gameService.ContinuePlaying((long)gameId, number); foreach (var player in gameStatistics.ShowGameViewItems) { if (player.PlayerStatus == PlayerStatus.Won) { return(View("~/Views/Game/GameResult.cshtml", gameStatistics.ShowGameViewItems)); } } return(View(gameStatistics.ShowGameViewItems)); } catch (Exception exeption) { return(View("~/Views/Shared/Error.cshtml", exeption)); } }