public static void Save(Visit v) { using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(v);//TODO Feiler her med GenericADOException dersom constrainten ikke oveholdes transaction.Commit(); } } }
private void MakeEmVisitUs() { for (int i = 0; i < 600; i++) { Kid k = (Kid)users[rand.Next(users.Count - 1)]; Visit v = new Visit(); v.KidId = k; DateTime d = new DateTime(rand.Next(2011, 2013), rand.Next(1, 13), rand.Next(1, 28)); v.VisitTime = d; v.SetRestrictionDate(); try { VisitProvider.Save(v); } catch (Exception e) { Console.WriteLine(e.StackTrace); } } }
private Boolean RegisterVisit(string kidName) { Visit v = new Visit(); Kid k = GetKid(kidName); v.KidId = k; using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.Save(v); transaction.Commit(); } catch (GenericADOException e) { Console.WriteLine(e.StackTrace); return false; } } } return true; }