public async Task AddGameCharacterToDbAsync(GameCharacterDTO model) { GameCharacter character = new GameCharacter(); mapper.Map(model, character); character.Vocation = ChangeVocationNameToShortForm(character.Vocation); await repository.Add(character); }
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")); }
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); }
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())); }
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")); }
public GameCharacterDTO MapDetailsFromApi(Character src, GameCharacterDTO dest) { return(mapper.Map(src, dest)); }