Exemplo n.º 1
0
        public SummonerVerificationModel Add(int userId, SummonerModel summonerModel)
        {
            Summoner existingSummoner = _summonerRepository.Get(summonerModel.Name, summonerModel.Region.Id);

            if (existingSummoner.IsVerified)
            {
                throw new BadRequestException("This League of Legends account has already been verified by somebody else.");
            }

            LeagueSummoner leagueSummoner = _apiService.GetSummoner(summonerModel.Region.Id, summonerModel.Name);

            string verificationCode = _secureTokenGenerator.GenerateToken(_verificationTokenLength);

            Summoner summoner = new Summoner()
            {
                LeagueApiId = leagueSummoner.Id,
                Name = leagueSummoner.Name,
                UserId = userId,
                Region = _regionRepository.GetFromLeagueId(summonerModel.Region.Id),
                VerificationCode = verificationCode,
                IsVerified = false
            };

            _summonerRepository.Add(summoner);

            return new SummonerVerificationModel()
            {
                Code = verificationCode,
                Summoner = _summonerModelMapper.ToModel(summoner)
            };
        }
Exemplo n.º 2
0
 public SummonerVerificationModel Post(int userId, SummonerModel summonerModel)
 {
     return _summonerService.Add(userId, summonerModel);
 }