public async Task <bool> Insert(List <Log> logs) { try { foreach (var log in logs) { var logId = await _dBContext.Log.Insert(log); if (logId > 0) { if (!await InsertUserAgents(log, logId)) { _dBContext.Rollback(); } } else { _dBContext.Rollback(); return(false); } } } catch { _dBContext.Rollback(); return(false); } _dBContext.Commit(); return(true); }
public void Test_Create_Child_ActivityDetail() { ChildActivityDetail cg = new ChildActivityDetail() { EventDate = DateTime.Today, StartTime = DateTime.Now, Child = new ChildDetail() { Key = 1 }, Activity = new ChildActivityType() { Key = 3 } }; NHibernateRepository ds = new NHibernateRepository(_sessionFactory); using (ctx = ctx.Start()) { ctx.BeginTransaction(); ds.Add(cg); ctx.Commit(); Console.WriteLine(cg.Key); Assert.That(cg.Key > 0); } }
public void Test_Create_Child_ActivityDetail() { ChildActivityDetail cg = new ChildActivityDetail() { EventDate = DateTime.Today, StartTime = DateTime.Now, Child = new ChildDetail() { Key = 1 }, Activity = new ChildActivityType() { Key = 3 } }; NHibernateRepository ds = new NHibernateRepository(_sessionFactory); using (ctx = ctx.Start()) { ctx.BeginTransaction(); ds.Add(cg); ctx.Commit(); Console.WriteLine(cg.Key); Assert.That(cg.Key > 0); } }