public void DodajOrganizacionuSemuTest() { var organizacionaSema = new OrganizacionaSema(); organizacionaSema.ImeOrganizacioneSeme = "Test"; organizacionaSema.ImeOrganizacioneSemeSkraceno = "TST"; using(ITransaction transaction = NHibernateSession.BeginTransaction()) { NHibernateSession.Save(organizacionaSema); transaction.Commit(); } var sema = (from seme in NHibernateSession.Linq<OrganizacionaSema>() where seme.OrganizacionaSemaId == organizacionaSema.OrganizacionaSemaId select seme).SingleOrDefault(); Assert.IsNotNull(sema); Assert.That(sema.ImeOrganizacioneSeme == "Test"); using (ITransaction transaction = NHibernateSession.BeginTransaction()) { NHibernateSession.Delete(organizacionaSema); transaction.Commit(); } sema = (from seme in NHibernateSession.Linq<OrganizacionaSema>() where seme.OrganizacionaSemaId == organizacionaSema.OrganizacionaSemaId select seme).SingleOrDefault(); Assert.IsNull(sema); }
public void DodajRadnikaTest() { var sema = new OrganizacionaSema(); sema.ImeOrganizacioneSeme = "Test"; sema.ImeOrganizacioneSemeSkraceno = "TST"; var radnik = new Radnik(); radnik.Ime = "Test"; radnik.Prezime = "Test"; radnik.Email = "*****@*****.**"; radnik.OrganizacionaSema = sema; using (ITransaction transaction = NHibernateSession.BeginTransaction()) { NHibernateSession.Save(sema); NHibernateSession.Save(radnik); transaction.Commit(); } var semaIzBaze = (from seme in NHibernateSession.Linq<OrganizacionaSema>() where seme.OrganizacionaSemaId == sema.OrganizacionaSemaId select seme).SingleOrDefault(); Assert.IsNotNull(semaIzBaze); Assert.That(semaIzBaze.ImeOrganizacioneSeme == "Test"); var radnikIzBaze = (from radnici in NHibernateSession.Linq<Radnik>() where radnici.RadnikId == radnik.RadnikId select radnici).SingleOrDefault(); Assert.IsNotNull(radnikIzBaze); Assert.That(radnikIzBaze.Ime == "Test"); Assert.That(radnikIzBaze.OrganizacionaSema.ImeOrganizacioneSeme == "Test"); using (ITransaction transaction = NHibernateSession.BeginTransaction()) { NHibernateSession.Delete(radnikIzBaze); NHibernateSession.Delete(semaIzBaze); transaction.Commit(); } semaIzBaze = (from seme in NHibernateSession.Linq<OrganizacionaSema>() where seme.OrganizacionaSemaId == sema.OrganizacionaSemaId select seme).SingleOrDefault(); radnikIzBaze = (from radnici in NHibernateSession.Linq<Radnik>() where radnici.RadnikId == radnik.RadnikId select radnici).SingleOrDefault(); Assert.IsNull(semaIzBaze); Assert.IsNull(radnikIzBaze); }
public void DodajOrganizacionuSemu(string imeOrganizacioneSeme) { var orgSema = new OrganizacionaSema { ImeOrganizacioneSeme = imeOrganizacioneSeme }; NHibernateSession.SaveOrUpdate(orgSema); using (ITransaction transaction = NHibernateSession.BeginTransaction()) { try { transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } }