示例#1
0
        public async Task <ActionResult <Challenge> > Create(ChallengeCreateDTO challengeDTO)
        {
            var httpResponse = await _riotService.GetSummonerId(challengeDTO.SummonerName);

            Challenge challenge = new Challenge {
                SummonerName = challengeDTO.SummonerName,
                Criterials   = challengeDTO.Criterials
            };

            if (httpResponse.Value != null)
            {
                challenge.SummonerId = httpResponse.Value;
            }
            else
            {
                return(httpResponse.Result);
            }

            challenge.Status = "open";
            _challengeService.Create(challenge);

            return(CreatedAtRoute("GetChallenge", new { id = challenge.Id.ToString() }, challenge));
        }