public async Task <IActionResult> CreateCharacter(CreateCharacterViewModel model) { var charactersQuantityInAccount = await _accountService.GetCharactersQuantity(User.Identity.Name); if (charactersQuantityInAccount >= 20) { return(RedirectToAction(nameof(Index), nameof(AccountController))); } if (ModelState.IsValid) { var dto = Mapper <CreateCharacterViewModel, CreateCharacterDTO>(model); try { await _characterService.CreateNewCharacter(dto, User.Identity.Name); LogInformation($"New Character Created. " + $"Account: {User.Identity.Name}, " + $"Character: {dto.Name}"); return(RedirectToAction(nameof(Index), nameof(AccountController))); } catch (CharacterAlreadyRegisteredException) { AddModelErrors(_localizer["CharacterAlreadyRegistered"]); } catch (Exception ex) { LogError(ex, nameof(AccountController), nameof(CreateCharacter)); AddModelErrors(_localizer["UnknownErrorContactAnAdmin"]); } } model.AllowedVocations = _characterService.GetVocationsOnCreate(); return(View(model)); }