public void First_we_need_a_schema_to_test() { var schemaExport = new SchemaExport(_cfg); schemaExport.Drop(true, true); schemaExport.Create(true, true); try { using (IUnitOfWork work = UnitOfWork.Start()) using (ITransaction transaction = work.BeginTransaction(IsolationLevel.Serializable)) { using (var repository = new NHibernateRepository()) { repository.Save(new TestSaga(_sagaId) { Name = "Joe" }); repository.Save(new TestSaga(CombGuid.Generate()) { Name = "Chris" }); work.Flush(); transaction.Commit(); } } } finally { UnitOfWork.Finish(); } }
public void Init() { using (var session = SessionManager.BuildSessionFactory().OpenSession()) { using (var tx = session.BeginTransaction()) { IRepository repository = new NHibernateRepository(session); var admin = repository.Query <User>() .FirstOrDefault(u => u.Username == "admin") ?? new User(); admin.Username = "******"; admin.Password = "******"; admin.Email = "*****@*****.**"; admin.Role = "admin"; repository.Save(admin); var anon = repository.Query <User>() .FirstOrDefault(u => u.Username == "anonymous") ?? new User(); anon.Username = "******"; anon.Password = ""; anon.Role = "user"; repository.Save(anon); tx.Commit(); } session.Close(); } }
public void Init() { using (var session = SessionManager.BuildSessionFactory().OpenSession()) { using (var tx = session.BeginTransaction()) { IRepository repository = new NHibernateRepository(session); var admin = repository.Query<User>() .FirstOrDefault(u => u.Username == "admin") ?? new User(); admin.Username = "******"; admin.Password = "******"; admin.Email = "*****@*****.**"; admin.Role = "admin"; repository.Save(admin); var anon = repository.Query<User>() .FirstOrDefault(u => u.Username == "anonymous") ?? new User(); anon.Username = "******"; anon.Password = ""; anon.Role = "user"; repository.Save(anon); tx.Commit(); } session.Close(); } }
public void TestSaveChangeIdOfTheEntity() { AnEntity ent = AnEntity.CreateSome(); sut.Save(ent); Assert.That(Invoker.GetProp <Int32>(ent, "Id"), Is.Not.EqualTo(0)); }
public void save_update_delete() { var playlist = new Playlist { Name = "New Playlist" }; _playlistRepo.Save(playlist); Assert.IsTrue(playlist.PlaylistId > 0); var playlistId = playlist.PlaylistId; playlist = _playlistRepo.Get(playlistId); Assert.IsNotNull(playlist); Assert.AreEqual(playlistId, playlist.PlaylistId); playlist.Name = "Updated Playlist"; _playlistRepo.Update(playlist); playlist = _playlistRepo.Get(playlistId); Assert.IsNotNull(playlist); Assert.AreEqual("Updated Playlist", playlist.Name); _playlistRepo.Delete(playlist); playlist = _playlistRepo.Get(playlistId); Assert.IsNull(playlist); }
private void AddBtn_Click(object sender, EventArgs e) { NHibernateRepository repo = new NHibernateRepository(); if (passwordtextBox.Text != confirmPasswordtextBox.Text) { MessageBox.Show("Please enter the same passord"); return; } if (userNametextBox.Text != "") { var users = repo.Query <User>(Expression.Eq("Name", userNametextBox.Text)); if (users.Count > 0) { MessageBox.Show("This user has already existed!"); return; } else { var newUser = new User { Name = userNametextBox.Text, Password = passwordtextBox.Text, IsAuthorized = authorizedcheckBox.Checked }; repo.Save(newUser); this.DialogResult = DialogResult.OK; this.Close(); return; } } }
private void SaveData(string cfg, IEnumerable <User> users) { var targetSessionManager = new NHibernateSessionManager(cfg); targetSessionManager.CreateDatabase(); using (var targetSession = targetSessionManager.BuildSessionFactory().OpenSession()) { using (var tx = targetSession.BeginTransaction()) { try { IRepository repository = new NHibernateRepository(targetSession); foreach (var user in users) { targetSession.Replicate(user, ReplicationMode.Exception); repository.Save(user); } tx.Commit(); } catch (Exception) { tx.Rollback(); throw; } } targetSession.Close(); } }
public void WriteListToDb() { var repository = new NHibernateRepository <Artist>(); NHibernateHelper.CreateDatabaseIfNeeded(); var testData = @"[{ ""Id"": 760, ""Name"": ""\""Weird Al\"" Yankovic"" }, { ""Id"": 3, ""Name"": "".38 Special"" }, { ""Id"": 1, ""Name"": ""3 Doors Down"" }]" ; var testObject = JSONToDatabaseReader.JSON.Serialization.Deserialize <List <Artist> >(testData); var resultingList = ReadJSONAndWriteToDb.FilterEnumerable(testObject, x => x.Name.Contains("3")); foreach (var item in resultingList) { repository.Save(item); } var nrOfArtists = repository.GetAll().Count; Assert.IsTrue(nrOfArtists == 2); }
static void Main(string[] args) { var flagRepostory= new NHibernateRepository<Flag>(); var langRepository = new NHibernateRepository<Language>(); var langInfoRepository= new NHibernateRepository<LanguageInfo>(); //var langInfo = langInfoRepository.GetAll(); var flags = flagRepostory.GetAll(); //var lang = langRepository.Get(2); //LanguageInfo langInfo = new LanguageInfo(); //langInfo.LongPath = "test"; //langInfo.ShortPath = "test1"; //langInfo.AddLanguage(lang); //lang.AddLanguageIcon(langInfo); //langRepository.Save(lang); //langInfoRepository.Save(langInfo); Flag flag = new Flag(); flag.Name = " F*****g programe"; flag.Description = " Flag Descrption2"; var lang = langRepository.Get(2); var languageInfo = new LanguageInfoNew { LongPath = "@C:Test1", ShortPath = "@d:tet2" }; languageInfo.AddLanguage(lang); //lang.AddLanguageIcon(new LanguageInfo { LongPath = "Test1", ShortPath = "test1" }); flag.AddLanguage(languageInfo); flagRepostory.Save(flag); }
public void PlaceOrder(Order order) { var repository = new NHibernateRepository <Order>(); var notifier = new PlainTextEmailer(); repository.Save(order); notifier.Send(order.Customer, "Your order was successfully processed."); }
public void Save_should_save_on_the_session() { var user = new User(); _repo.Save(user); _session.AssertWasCalled(s => s.SaveOrUpdate(user)); }
public void PlaceOrder(Order order) { var repository = new NHibernateRepository<Order>(); var notifier = new PlainTextEmailer(); repository.Save(order); notifier.Send(order.Customer, "Your order was successfully processed."); }
protected override void LoadTestData() { var repository = new NHibernateRepository<Product>(); for (var id = 1; id <= 100; ++id) { var name = string.Format("Product {0:d3}", id); var product = new Product { ProductName = name }; repository.Save(product); } }
private static void AddUserAccountWithDepartmentsInBatch() { NHibernateRepository <Department> dptRepository = new NHibernateRepository <Department>(); dptRepository.Insert(new Department { DepartmentName = "Department 100" }); dptRepository.Insert(new Department { DepartmentName = "Department 200" }); dptRepository.Insert(new Department { DepartmentName = "Department 300" }); dptRepository.Insert(new Department { DepartmentName = "Department 400" }); dptRepository.Insert(new Department { DepartmentName = "Department 500" }); dptRepository.Save(); List <Department> dpts = dptRepository.All().ToList(); NHibernateRepository <UserAccount> accountsRepository = new NHibernateRepository <UserAccount>(); for (int i = 0; i < 5000; i++) { UserAccount acct = new UserAccount(); acct.Email = "mscsharp_" + i + "@gmail.com"; acct.Password = i + "_password"; acct.Username = "******" + i; Department rndDpt = dpts[new Random().Next(dpts.Count)]; //if (i < 100) // acct.Department = dpts.Find(x => x.DepartmentName.Contains("100")); //else if (i < 200) // acct.Department = dpts.Find(x => x.DepartmentName.Contains("200")); //else if (i < 300) // acct.Department = dpts.Find(x => x.DepartmentName.Contains("300")); //else if (i < 400) // acct.Department = dpts.Find(x => x.DepartmentName.Contains("400")); //else if (i < 500) // acct.Department = dpts.Find(x => x.DepartmentName.Contains("500")); acct.Department = rndDpt; accountsRepository.Insert(acct); } accountsRepository.Save(); }
public void QueryUser() { var repo = new NHibernateRepository(); var users = repo.Query <User>(Expression.Eq("Name", "admin")); Assert.AreEqual(0, users.Count); User u = new User() { Name = "admin", Password = "******" }; repo.Save(u); }
/// <summary> /// Método para guardar un proveedor. /// </summary> /// <param name="proveedor"></param> public void GuardarProveedor(Proveedor proveedor) { try { IRepository <Proveedor> pRepo = new NHibernateRepository <Proveedor>(); pRepo.Save(proveedor); } catch (Exception e) { log.Error(e.Message, e); throw new DataAccessException(DataAccessException.EXCEPTION, e); } }
/// <summary> /// Método para guardar un usuario. /// </summary> /// <param name="usuario"></param> public void GuardarUsuario(Usuario usuario) { try { IRepository <Usuario> uRepo = new NHibernateRepository <Usuario>(); uRepo.Save(usuario); } catch (Exception e) { log.Error(e.Message, e); throw new DataAccessException(DataAccessException.EXCEPTION, e); } }
private static void AddCitys() { NHibernateRepository <City> cityRepository = new NHibernateRepository <City>(); City c = new City() { Name = "c1", Population = 2000000, Municipality = new Municipality { Name = "M1" } }; cityRepository.Insert(c); cityRepository.Save(); }
public void SaveCustomer() { Customer customer = null; //create a session provide, provide the current database session ISessionProvider sessionProvider = new SessionProvider(); //a generic repository that handles saving the entity to // the database NHibernateRepository<Customer> customerRepository = new NHibernateRepository<Customer>(sessionProvider); //save the customer to the database customerRepository.Save(customer); }
public void MappingTest() { var testObject = new Artist { Id = 123, Name = "TestBoodschap" }; var repository = new NHibernateRepository <Artist>(); NHibernateHelper.CreateDatabaseIfNeeded(); repository.Save(testObject); var result = repository.Get(123); Assert.IsTrue(testObject == result); Assert.IsTrue(repository.GetAll().Count > 0); }
private NHibernateRepository <Song> Prepare() { var firstrun = !System.IO.File.Exists("test.db"); if (firstrun) { NHibernateHelper.CreateDatabaseIfNeeded(); var repository = new NHibernateRepository <Song>(); var filename = Configuration["JSONSongFile"]; var songlist = JSONToDatabaseReader.ReadJSONAndWriteToDb.ReadFile <List <Song> >(filename); var filteredsonglist = JSONToDatabaseReader.ReadJSONAndWriteToDb.FilterEnumerable(songlist, x => x.Genre.Contains("Metal") && x.Year < 2016); foreach (var item in filteredsonglist) { repository.Save(item); } return(repository); } return(new JSONToDatabaseReader.Repository.NHibernateRepository <Song>()); }
public void IntegrationTest() { IList<Banana> bananas = new List<Banana>(); bananas.Add(new Banana() { Color = "Brown" }); bananas.Add(new Banana() { Color = "Yellow" }); IRepository<Banana> bRepo = new NHibernateRepository<Banana>(); foreach (Banana b in bananas) bRepo.Save(b); Assert.IsTrue(bRepo.GetAll().Count == bananas.Count); IList<Monkey> monkeys = new List<Monkey>(); monkeys.Add(new Monkey() { Name = "George", FlingsPoo = true, Bananas = bananas }); monkeys.Add(new Monkey() { Name = "Magilla", FlingsPoo = false }); IRepository<Monkey> mRepo = new NHibernateRepository<Monkey>(); foreach (Monkey m in monkeys) mRepo.Save(m); Assert.IsTrue(mRepo.GetAll().Count == monkeys.Count); Monkey tempMonkey; tempMonkey = mRepo.Get(monkeys[0].Id); Assert.IsNotNull(tempMonkey); tempMonkey = mRepo.Get(-1); Assert.IsNull(tempMonkey); IMonkeyRepository imRepo = new MonkeyRepository(); Assert.IsTrue(imRepo.GetPooFlingingMonkeys().Count == 1); foreach (Banana b in bananas) bRepo.Delete(b); Assert.IsTrue(bRepo.GetAll().Count == 0); foreach (Monkey m in monkeys) mRepo.Delete(m); Assert.IsTrue(mRepo.GetAll().Count == 0); }
public void GenerateSchemaAndData() { var cfg = new global::NHibernate.Cfg.Configuration().Configure(); new SchemaExport(cfg) .SetDelimiter(";") .Execute(false, true, false); var random = new Random(); Func<DateTime> before2000 = () => new DateTime(random.Next(1950, 2000), random.Next(1, 13), random.Next(1, 29)); Func<DateTime> before2005 = () => new DateTime(random.Next(2000, 2005), random.Next(1, 13), random.Next(1, 29)); //some user data var users = new[] { new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User {Created = DateTime.Now, Email = "*****@*****.**", Username = "******" }, new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2000(), Email = "*****@*****.**", Username = "******" }, new User { Email = "*****@*****.**", Username = "******" }, new User { Email = "*****@*****.**", Username = "******" }, new User { Email = "*****@*****.**", Username = "******" }, new User { Email = "*****@*****.**", Username = "******" }, new User {Created = before2005(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2005(), Email = "*****@*****.**", Username = "******" }, new User {Created = before2005(), Email = "*****@*****.**", Username = "******" }, new User { Email = "*****@*****.**", Username = "******" }, }; using (var sessionFactory = cfg.BuildSessionFactory()) { using (var session = sessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { var repo = new NHibernateRepository<User>(session); users.Walk(user => repo.Save(user)); tx.Commit(); } } } }
public void Saving_a_state_machine_should_work() { Guid transactionId; using (var unitOfWork = UnitOfWork.Start()) using (var transaction = unitOfWork.BeginTransaction(IsolationLevel.Serializable)) { using(var repository = new NHibernateRepository() ) { ExampleStateMachine machine = new ExampleStateMachine(); repository.Save(machine); transactionId = machine.TransactionId; } transaction.Commit(); } UnitOfWork.Finish(); using (var unitOfWork = UnitOfWork.Start()) using (var transaction = unitOfWork.BeginTransaction(IsolationLevel.Serializable)) { using (var repository = new NHibernateRepository()) { ExampleStateMachine machine = repository.Get<ExampleStateMachine>(transactionId); machine.SubmitOrder(); repository.Update(machine); } transaction.Commit(); } UnitOfWork.Finish(); }
public void Saving_a_state_machine_should_work() { Guid transactionId; using (var unitOfWork = UnitOfWork.Start()) using (var transaction = unitOfWork.BeginTransaction(IsolationLevel.Serializable)) { using (var repository = new NHibernateRepository()) { ExampleStateMachine machine = new ExampleStateMachine(); repository.Save(machine); transactionId = machine.TransactionId; } transaction.Commit(); } UnitOfWork.Finish(); using (var unitOfWork = UnitOfWork.Start()) using (var transaction = unitOfWork.BeginTransaction(IsolationLevel.Serializable)) { using (var repository = new NHibernateRepository()) { ExampleStateMachine machine = repository.Get <ExampleStateMachine>(transactionId); machine.SubmitOrder(); repository.Update(machine); } transaction.Commit(); } UnitOfWork.Finish(); }
public void Add(DeferredMessage message) { _repository.Save(message); }
static void Main(string[] args) { //create tables from mapping new SchemaExport(NHibernateHelper.Configuration).Create(false, true); #region use_inline //open connection to db using (ISession session = NHibernateHelper.SessionFactory.OpenSession()) { #region add using (ITransaction tx = session.BeginTransaction()) { for (int i = 0; i < 30; i++) { var employee = new Employee { Name = new Name { FirstName = "Employee", LastName = string.Format("{0}", i) } }; var employer = new Employer { Name = string.Format("Employer {0}", i) }; var employment = new Employment { Employee = employee, Employer = employer, StartDate = System.DateTime.Now, EndDate = System.DateTime.Now.AddDays(i) }; session.Save(employee); session.Save(employer); session.Save(employment); } tx.Commit(); } #endregion #region list using (var tx = session.BeginTransaction()) { //dont forget ToList() var employments = session.Query <Employment>().ToList(); foreach (var employment in employments) { Console.Out.WriteLine("Employee: " + employment.Employee.Name.LastName + " end date " + employment.EndDate + " at employer " + employment.Employer.Name); } tx.Commit(); } #endregion } #endregion #region using_repository IRepository <Employment> EmploymentRepository = new NHibernateRepository <Employment>(); IRepository <Employee> EmployeeRepository = new NHibernateRepository <Employee>(); IRepository <Employer> EmployerRepository = new NHibernateRepository <Employer>(); #region add for (int i = 0; i < 30; i++) { var employee = new Employee { Name = new Name { FirstName = "Employee", LastName = string.Format("{0}", i) } }; var employer = new Employer { Name = string.Format("Employer {0}", i) }; var employment = new Employment { Employee = employee, Employer = employer, StartDate = System.DateTime.Now, EndDate = System.DateTime.Now.AddDays(i) }; EmployeeRepository.Save(employee); EmployerRepository.Save(employer); EmploymentRepository.Save(employment); } #endregion #region show foreach (var employment in EmploymentRepository.GetAll()) { Console.Out.WriteLine("Employee: " + employment.Employee.Name.LastName + " end date " + employment.EndDate + " at employer " + employment.Employer.Name); } #endregion #endregion }
private void SaveData(string cfg, IEnumerable<User> users) { var targetSessionManager = new NHibernateSessionManager(cfg); targetSessionManager.CreateDatabase(); using (var targetSession = targetSessionManager.BuildSessionFactory().OpenSession()) { using (var tx = targetSession.BeginTransaction()) { try { IRepository repository = new NHibernateRepository(targetSession); foreach (var user in users) { targetSession.Replicate(user, ReplicationMode.Exception); repository.Save(user); } tx.Commit(); } catch (Exception) { tx.Rollback(); throw; } } targetSession.Close(); } }
//http://aabs.wordpress.com/2008/01/18/c-by-contract-using-expression-trees/ static void Main(string[] args) { Console.WriteLine("Creating Tables..."); var sessionFactory = new SessionFactory(); Console.WriteLine("Finished Creating Tables!"); Console.WriteLine("inserting new data..."); IRepository repository = new NHibernateRepository(sessionFactory); foreach (var str in ConfigurationManager.ConnectionStrings) { if (!str.ToString().Contains("server=localhost") && !str.ToString().Contains(".\\SQLEXPRESS") && !str.ToString().Equals(String.Empty)) { Console.WriteLine("WTF? Don't run this on a remote server!"); Console.ReadKey(); return; } } try { repository.BeginTransaction(); //stas 664118894 var fbUser1 = new FbUser { Id = 585701767, JoinDate = DateTime.Now, Name = "anna", Status = UserStatus.Joined }; var fbUser2 = new FbUser { Id = 806905557, JoinDate = DateTime.Now, Name = "stas", Status = UserStatus.Joined }; var fbUser3 = new FbUser { Id = 716712905, JoinDate = DateTime.Now, Name = "dror", Status = UserStatus.Joined }; //var fbUser3 = new FbUser { Id = 806905557, JoinDate = DateTime.Now, Name = "ran", Status = UserStatus.Joined }; var fbUser4 = new FbUser { Id = 100000431166374, JoinDate = DateTime.Now, Name = "yadid", Status = UserStatus.Joined }; repository.Save(fbUser1); repository.Save(fbUser2); repository.Save(fbUser3); repository.Save(fbUser4); var localBusiness1 = new LocalBusiness { AddressCity = "Yehud", AddressStreet = "Levi Eschol 1", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "http://www.facebook.com/pages/%D7%A7%D7%95%D7%9C%D7%95%D7%9C%D7%95/178456328876503", FanPageId = 186841648018387, //FanPageId = 258829897475960, LastModified = DateTime.Now, Name = "קולולו", PublishUserContentToWall = false, PublishAdminContentToWall = true, Owners = new List<FbUser> { fbUser1, fbUser2, fbUser3, fbUser4 } }; var uriBusiness = new LocalBusiness { AddressCity = "Faraway city", AddressStreet = "Back alley", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "https://www.facebook.com/pages/%D7%96%D7%9E%D7%A8-test/245866165438909", FanPageId = 245866165438909, FBFanPageAccessToken = "157721837628308|afd07c5be8ae8e01047a1156.1-662326561|juC8P9wsNLP5XirWXPCzEMF7qPU", ImageUrl = "https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yA/r/gPCjrIGykBe.gif", LastModified = DateTime.Now, Name = "זמר טסט", PublishUserContentToWall = true, PublishAdminContentToWall = true, Owners = new List<FbUser> {fbUser1, fbUser2, fbUser3, fbUser4} }; var uriRadio = new Playlist { Name = "Radio Uri", Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, NextPlayDate = DateTime.Parse("23/07/2013 08:55:00"), IsUserModifyable = true, NumOfSongsLimit = 5 }; uriBusiness.AddPlaylist(uriRadio); uriBusiness.ImportPlaylist = uriRadio; repository.Save(uriBusiness); var radio1 = new Playlist { Name = "Kululu-FM", Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, NextPlayDate = DateTime.Parse("23/07/2012 08:55:00"), IsUserModifyable = true, NumOfSongsLimit = 5 }; localBusiness1.AddPlaylist(radio1); localBusiness1.ImportPlaylist = radio1; repository.Save(localBusiness1); var localBusiness2 = new LocalBusiness() { Owners = new List<FbUser> { fbUser1 }, AddressCity = "Haifa", AddressStreet = "Rauel Wallenberg", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "http://www.facebook.com/pages/%D7%A7%D7%95%D7%9C%D7%95%D7%9C%D7%95/178456328876503", FanPageId = 1, ImageUrl = "http://profile.ak.fbcdn.net/hprofile-ak-snc4/195725_178456328876503_4279627_n.jpg", LastModified = DateTime.Now, PublishAdminContentToWall = true, PublishUserContentToWall = false, Name = "Kululu Test" }; var radio2 = new Playlist { Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, Name = "Radius-100FM", NextPlayDate = DateTime.Parse("25/07/2011"), IsUserModifyable = true, NumOfSongsLimit = 10 }; localBusiness2.AddPlaylist(radio2); repository.Save(localBusiness2); var playlistSongRating = SaveSong(repository, radio1, fbUser1, "Cee Lo Green", "Bright Lights Bigger City", 231, "UBhdIcb84Hw", 1, "http://userserve-ak.last.fm/serve/126s/62075863.png"); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, 1); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); uriRadio.RateSong(playlistSongRating, fbUser4, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "מוש בן ארי", "סתכל לי בעיניים", 249, "HwgVLsnaAoU", 1, "http://userserve-ak.last.fm/serve/126s/20443621.jpg"); //radio1.AddRating(song, fbUser3, 1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, 1); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); uriRadio.RateSong(playlistSongRating, fbUser4, 1); uriRadio.RateSong(playlistSongRating, fbUser2, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "J.LO FT. Pitbull", "On The Floor", 267, "t4H_Zoh7G5A", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "גלעד שגב", "חנה'לה התבלבלה", 214, "vAlFB4Z7P2Y", 1, "http://userserve-ak.last.fm/serve/126s/163895.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Adele", "Someone Like You", 306, "7AW9C3-qWug", 1, "http://userserve-ak.last.fm/serve/126s/58297847.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); SaveSong(repository, radio1, fbUser1, "Britney Spears", "Till The World Ends", 236, "qzU9OrZlKb8", 1, "http://userserve-ak.last.fm/serve/126s/59558187.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); SaveSong(repository, radio1, fbUser1, "Enrique Iglesias", "Tonight", 299, "Jx2yQejrrUE", 1, "http://userserve-ak.last.fm/serve/126s/65262750.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Pitbull", "Give Me Everything", 267, "EPo5wWmKEaI", 1, "http://userserve-ak.last.fm/serve/126s/64990460.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, -1); uriRadio.RateSong(playlistSongRating, fbUser4, 1); uriRadio.RateSong(playlistSongRating, fbUser2, -1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Lady Gaga", "Born This Way", 440, "wV1FrqwZyKw", 1, "http://userserve-ak.last.fm/serve/126s/63387017.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "ברי סחרוף", "זמן של מספרים", 303, "PCwDDGYely0", 1, "http://userserve-ak.last.fm/serve/126s/784256.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Depeche Mode", "Personal Jesus (The Stargate Mix)", 252, "3xLvArgSp3k", 1, "http://userserve-ak.last.fm/serve/126s/2126897.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Diddy Dirty Money ft. Skylar Grey", "Coming Home", 251, "k-ImCpNqbJw", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "The Black Eyed Peas", "Just Can't Get Enough", 236, "OrTyD7rjBpw", 1, "http://userserve-ak.last.fm/serve/126s/65970878.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Bob Sinclar & Raffaella Carrà", "Far l'Amore", 220, "rSmdeqxxLLk", 1, "http://userserve-ak.last.fm/serve/126s/26932877.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Jessie J ft. B.o.B.", "Price Tag", 247, "qMxX-QOV9tI", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, -1); radio1.RateSong(playlistSongRating, fbUser2, -1); uriRadio.RateSong(playlistSongRating, fbUser4, -1); uriRadio.RateSong(playlistSongRating, fbUser2, -1); //radio2.AddRating(song, fbUser3, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Lady Gaga", "The Edge Of Glory", 328, "QeWBS0JBNzQ", 1, "http://userserve-ak.last.fm/serve/126s/63387017.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //SaveSong(repository, radio1, fbUser1, "הפרוייקט של עידן רייכל - אִמָּא, אַבָּא וכל הַשְּׁאָר", "D98E89oUo6o", 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "אדיר גץ", "איך היא רוקדת", 236, "Pu2s7bboV9M", 1, "http://userserve-ak.last.fm/serve/126s/51539323.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "שלומי סרנגה", "זה רק נדמה לך", 218, "MaZIYKtIfnM", 1, "http://userserve-ak.last.fm/serve/126s/83144.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "מאור כהן", "ישראל", 183, "svjdhfKJbUc", 1, "http://userserve-ak.last.fm/serve/126s/311813.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio2.RateSong(song, fbUser2, 1); //radio2.AddRating(song, fbUser3, 1); repository.CommitTransaction(); } catch (Exception e) { repository.RollbackTransaction(); repository.CloseSession(); Console.WriteLine("*** Failure ({0}): {1}", e.GetType(), e.Message); } Console.WriteLine("Finished!"); Console.ReadKey(); }