public RedirectToActionResult CharacterCreator(string userName, string name, string species, string gender, string description, string ability1, string ability2, string ability3, string ability4, string ability5) { Character character = new Character(name, gender, species, description) { IsPlayer = true, IsMonster = false, IsNPC = false }; character.Abilities.Add(ability1); character.Abilities.Add(ability2); character.Abilities.Add(ability3); character.Abilities.Add(ability4); character.Abilities.Add(ability5); cRepo.AddCharacter(character); User user; if (!uRepo.CheckForUserByUserName(userName)) { user = new User(); user.UserName = userName; uRepo.AddUser(user); } else { user = uRepo.GetUserByUserName(userName); } user.Characters.Add(character); return(RedirectToAction("Member", new { userName = user.UserName })); }
public HomeController(IUserRepo uR, ICharacterRepo cR) { uRepo = uR; cRepo = cR; if (uRepo.Users.Count == 0) { User user = new User() { Email = "*****@*****.**", Name = "Sandra Heart", UserName = "******", Password = "******" }; uRepo.AddUser(user); user = new User() { Email = "*****@*****.**", Name = "Phillip Grey", UserName = "******", Password = "******" }; uRepo.AddUser(user); } if (cRepo.Characters.Count == 0) { User user = uRepo.GetUserByName("Phillip Grey"); Character character = new Character() { Name = "Alphie, Terror of the Night", IsMonster = true, IsNPC = false, IsPlayer = false, Species = "Pig Monster", Gender = "male", Description = "Orange, short, fat, large fangs." }; character.Abilities.Add("Sharp claws and fangs that can kill and maim."); character.Abilities.Add("Piercing red eyes for hypnotizing prey."); character.Abilities.Add("A cruel laugh that paralyzes all who hear it."); cRepo.AddCharacter(character); user.Characters.Add(character); character = new Character() { Name = "Cleo SharpTongue", IsMonster = false, IsNPC = true, IsPlayer = false, Species = "Halfling", Gender = "female", Description = "Small, but tough bartender. Spends her days adventuring" + "and her nights busting heads at her tavern. She has brown hair and" + "brown eyes, and if you don't try to mess with her, her smile will " + "melt your heart." }; character.Abilities.Add("Handy with a sword."); character.Abilities.Add("Makes a mean ale."); character.Abilities.Add("A killer stare that makes grown men run to their mamas."); cRepo.AddCharacter(character); user.Characters.Add(character); } }
public async Task <IActionResult> AddCharacter(AddCharacterDto newCharacter) { ServiceResponse <List <GetCharacterDto> > response = await _repository.AddCharacter(newCharacter); return(CreatedAtRoute(nameof(GetAll), new { Id = response.Data[0].Id }, response.Data)); }