static void Main(string[] args) { var sessionFactory = HibernateSession.SessionFactory(); var session = sessionFactory.OpenSession(); BandDAO bandDAO = new BandDAO(session); var band = new Band(); band.BandName = "PanterA"; using (var transaction = session.BeginTransaction()) { bandDAO.Save(band); transaction.Commit(); } Console.ReadKey(); }
public void VotesPerBand_ShouldReturnOne() { Band myNewBand = new Band(); myNewBand.BandName = "My Band"; bandDao.Save(myNewBand); var bandSong = new Band() { BandName = "Ozzy Osbourne" }; bandDao.Save(bandSong); Song song = new Song(); song.Band = bandSong; song.SongName = "Crazy Train"; songDao.Save(song); Vote vote = new Vote(); vote.VotedBand = myNewBand; vote.VotedSong = song; vote.VotingDate = DateTime.Now; voteDao.Save(vote); IList<Vote> votesCasted = voteDao.VotesCastedTo(myNewBand); Assert.AreEqual(1, votesCasted.Count); }
public IEnumerable<VotesPerSong> AllVotesPerSongForBand(Band band) { var bandVotes = this.VoteDAO.VotesCastedTo(band); var sumOfVotes = from vote in bandVotes group vote by vote.VotedSong into votePerSong select new VotesPerSong() { Song = votePerSong.Key, NumberOfVotes = votePerSong.Count() }; return sumOfVotes; }
public void Save(Band entity) { this.bandDAO.Save(entity); }
public void Delete(Band entity) { this.bandDAO.Delete(entity); }
public void SetUp() { this.voteDAO = new Mock<IVoteDAO>(); this.votePoll = new VotePoll(voteDAO.Object); this.band = new Band(); }