private IEnumerable <CharacterToEpisodeXref> BuildCharacterToEpisodeXrefsList() { var characterToEpisodeList = new List <CharacterToEpisodeXref>(); for (int i = 1; i <= 7; i++) { if (i == 5) { var characterToEpisode = new CharacterToEpisodeXref { CharacterId = i, EpisodeId = 1 }; characterToEpisodeList.Add(characterToEpisode); } else { for (int j = 1; j <= 3; j++) { var characterToEpisode = new CharacterToEpisodeXref { CharacterId = i, EpisodeId = j }; characterToEpisodeList.Add(characterToEpisode); } } } return(characterToEpisodeList); }
public async Task <IActionResult> CreateCharacterToEpisodeXref([FromBody] CreateCharacterToEpisodeXref data) { var characterToEpisodeXref = new CharacterToEpisodeXref { CharacterId = data.CharacterId, EpisodeId = data.EpisodeId }; await _context.AddAsync(characterToEpisodeXref); await _context.SaveChangesAsync(); return(Created(characterToEpisodeXref.Id.ToString(), new FriendViewModel { Id = characterToEpisodeXref.Id, CharacterId = characterToEpisodeXref.CharacterId, FriendId = characterToEpisodeXref.EpisodeId })); }