public async Task <IActionResult> CreateCharacter(CreateCharacterViewModel characterViewModel) { var character = Mapper.Map <Character>(characterViewModel); character = _characterService.Add(character); await _dbContext.SaveChangesAsync(); await _cachingService.RemoveAsync($"{nameof(Character)}s"); return(Created("characters", character.Id)); }
public void SeedCharacterData(WebCharacter character, ICharacterService characterService, IMovementService movementService, IMoveService moveService, ICharacterAttributeRowService characterAttributeRowService, IUniqueDataService uniqueDataService) { Guard.VerifyObjectNotNull(character, nameof(character)); Guard.VerifyObjectNotNull(characterService, nameof(characterService)); Guard.VerifyObjectNotNull(movementService, nameof(movementService)); Guard.VerifyObjectNotNull(moveService, nameof(moveService)); Guard.VerifyObjectNotNull(characterAttributeRowService, nameof(characterAttributeRowService)); Guard.VerifyObjectNotNull(uniqueDataService, nameof(uniqueDataService)); _characterDataScraper.PopulateCharacterFromWeb(character); var entityCharacter = Mapper.Map <Character>(character); characterService.Add(entityCharacter); movementService.AddMany(character.Movements); moveService.AddMany(character.Moves); characterAttributeRowService.AddMany(character.AttributeRows); uniqueDataService.AddMany(character.UniqueProperties); }