public void Add(ServiceEvent serviceEvent) { using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(serviceEvent); transaction.Commit(); } } }
public void Can_add_new_service_event() { var serviceEvent = new ServiceEvent { Description = "Desc", State = "Open", Created = new DateTime(2011, 3, 4, 5, 6, 7) }; IServiceEventRepository repository = new ServiceEventRepository(); repository.Add(serviceEvent); // use session to try to load the service using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<ServiceEvent>(serviceEvent.EventId); Assert.IsNotNull(fromDb); Assert.AreNotSame(serviceEvent, fromDb); Assert.AreEqual(serviceEvent.State, fromDb.State); Assert.AreEqual(serviceEvent.Description, fromDb.Description); Assert.AreEqual(serviceEvent.EventId, fromDb.EventId); Assert.AreEqual(serviceEvent.ServiceId, fromDb.ServiceId); Assert.AreEqual(serviceEvent.Created, fromDb.Created); } }
public ViewResult Index(string verb) { var serviceEvent = new ServiceEvent { State = "down" }; return View("Index",serviceEvent); }
public ViewResult Details(string name) { var serviceEvent = new ServiceEvent { State = "up" }; return View("Details",serviceEvent); }