private static void CreateAndAddVotingCandidate(int number, int numberOfVotes, IVotingCandidateRepository votingCandidateRepository, IVoteRepository voteRepository, ISongRepository songRepository) { var song = songRepository.Create(); song.Title = "SongRepositoryTests" + number; song.DurationInSeconds = 120; song.FileName = "SongRepositoryTests.mp3"; songRepository.Add(song); var votingCandidate = votingCandidateRepository.Create(); votingCandidate.SongId = song.Id; votingCandidate.Song = song; votingCandidate.DisplayOrder = number; votingCandidateRepository.Add(votingCandidate); foreach (var index in Enumerable.Range(0, numberOfVotes)) { var vote = voteRepository.Create(); vote.VotingCandidateId = votingCandidate.Id; vote.VotingCandidate = votingCandidate; vote.UserIdentifier = Guid.NewGuid(); voteRepository.Add(vote); } }
private IEnumerable <VotingCandidate> AddNewVotingCandidates(IEnumerable <Song> songs) { foreach (var item in songs.Select((song, index) => new { song, index })) { var votingCandidate = _votingCandidateRepository.Create(); _votingCandidateRepository.Add(votingCandidate); votingCandidate.Map(song: item.song, displayOrder: item.index); yield return(votingCandidate); } }