Esempio n. 1
0
 public void AddUser(User user)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Save(user);
         transaction.Commit();
     }
 }
Esempio n. 2
0
        public void CanAddUser()
        {
            var user = new User
            {
                FirstName = "Ivan",
                LastName = "Ivanov",
                CityId = new Guid("A3F997ED-0A93-4A95-B50A-0000025C49F6")
            };
            IUserRepository repository = new UserRepository();
            repository.AddUser(user);

            using (ISession session = NHibernateHelper.OpenSession())
            {
                var fromDb = session.Get<User>(user.Id);
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(user, fromDb);
                Assert.AreEqual(user.FirstName, fromDb.FirstName);
                Assert.AreEqual(user.LastName, fromDb.LastName);
            }
        }
 public void AddUser(User user)
 {
     UserRepository.AddUser(user);
 }