Пример #1
0
        public async Task <ActionResult <Highscore> > PostHighscore(HighscoreDto highscore)
        {
            HttpClient httpClient = new HttpClient();
            var        res        = httpClient.GetAsync($"https://www.google.com/recaptcha/api/siteverify?secret=" + _configuration["GoogleReCaptcha:secret"] + "&response=" + highscore.captcha).Result;

            if (res.StatusCode != HttpStatusCode.OK)
            {
                return(BadRequest("You are a bot!"));
            }

            string  response = res.Content.ReadAsStringAsync().Result;
            dynamic JSONdata = JObject.Parse(response);

            if (JSONdata.success != "true")
            {
                return(BadRequest("You are a bot!"));
            }

            return(await AddHighscore(highscore.Highscore));
        }
Пример #2
0
        public async Task <IActionResult> HighScore(HighscoreDto highScoreDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var player = await playerRepository.GetPlayerById(highScoreDto.PlayerId);

            if (player == null)
            {
                return(BadRequest());
            }

            var result = await highscoreRepository.AddHighscore(player, highScoreDto.HighScore);

            if (result)
            {
                return(Ok());
            }

            return(BadRequest());
        }