예제 #1
0
        public async Task AddGameCharacterToDbAsync(GameCharacterDTO model)
        {
            GameCharacter character = new GameCharacter();

            mapper.Map(model, character);
            character.Vocation = ChangeVocationNameToShortForm(character.Vocation);

            await repository.Add(character);
        }
예제 #2
0
        public async Task <IActionResult> Verify(GameCharacterDTO model)
        {
            var isTokenVerificationValid = characterService.VerifyToken(model);

            if (isTokenVerificationValid)
            {
                model.ApplicationUser = _userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result;
                await characterService.AddGameCharacterToDbAsync(model);

                return(RedirectToAction("MyCharacterList", "Account"));
            }
            return(Content("Error"));
        }
예제 #3
0
        public bool VerifyToken(GameCharacterDTO model)
        {
            var character = GetCharacterDetailsIfExists(model.CharacterName);

            if (character.characters.data.comment != null)
            {
                if (character.characters.data.comment.Contains(model.VerificationToken))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        public IActionResult VerifyCheck(string characterName, string verificationToken)
        {
            GameCharacterDTO model = new GameCharacterDTO()
            {
                VerificationToken = verificationToken,
                CharacterName     = characterName.Replace('_', ' ')
            };

            if (characterService.VerifyToken(model))
            {
                return(Content("Token correct! Click verify to add this character to your account."));
            }
            return(Content("Check failed. Maybe your character info didn't yet update or you pasted wrong code. If pasted code is correct try again within 5 minutes. Last check: " + DateTime.Now.ToShortTimeString()));
        }
예제 #5
0
        public IActionResult VerifyCharacter(GameCharacterDTO model)
        {
            var character = characterService.GetCharacterDetailsIfExists(model.CharacterName);

            if (character.characters.error == null)
            {
                if (characterService.CheckIfCharacterIsAlreadyOwned(model.CharacterName))
                {
                    TempData["ErrorMessage"] = "This character was already assigned";
                    return(RedirectToAction("AddCharacter"));
                }

                model = characterService.MapDetailsFromApi(character, model);
                model.VerificationToken = Guid.NewGuid().ToString();
                return(View(model));
            }

            TempData["ErrorMessage"] = "This character does not exist";
            return(RedirectToAction("AddCharacter"));
        }
예제 #6
0
 public GameCharacterDTO MapDetailsFromApi(Character src, GameCharacterDTO dest)
 {
     return(mapper.Map(src, dest));
 }