Пример #1
0
        private async void SendHangmanWordToAPI(HangmanWordDTO wordDTO)
        {
            var        game   = JsonConvert.SerializeObject(wordDTO);
            HttpClient client = new HttpClient();
            var        res    = await client.PutAsync("http://localhost:5000/api/Game/word", new StringContent(game, System.Text.Encoding.UTF8, "application/json"));

            RefreshGames();
        }
Пример #2
0
 public ActionResult SetWordForHangmanGame([FromBody] HangmanWordDTO dto)
 {
     try
     {
         return(Ok(GameService.SetWordForGame(dto)));
     }
     catch (ArgumentException)
     {
         return(NotFound());
     }
 }
Пример #3
0
        public bool SetWordForGame(HangmanWordDTO dto)
        {
            var game = (HangmanGame)games
                       .Include(g => g.GamePair).ThenInclude(g => g.FirstGame).ThenInclude(g => g.Player)
                       .Include(g => g.GamePair).ThenInclude(g => g.SecondGame).ThenInclude(g => g.Player)
                       .SingleOrDefault(s => s.GameId == dto.GameId) ?? throw new ArgumentException();

            game.SetWord(dto.Word);
            games.Update(game);
            context.SaveChanges();
            return(true);
        }