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 bool ConfirmSummoner(Summoner summoner)
        {
            RunepagesDTO runepagesDto = _leagueRequestService.GetRunepages(summoner.Region.LeagueApiId, summoner.LeagueApiId);

            return runepagesDto.Pages.Any(rp => rp.Name == summoner.VerificationCode);
        }
Exemplo n.º 3
0
 public void Update(Summoner summoner)
 {
 }
Exemplo n.º 4
0
 public void Delete(Summoner summoner)
 {
 }
Exemplo n.º 5
0
 public void Add(Summoner summoner)
 {
     summoner.Id = 1;
 }