public void Update(Submitter user)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Update(user);
         transaction.Commit();
     }
 }
 private static bool IsInSubmitterNameCollection(Submitter submitter, IEnumerable<Submitter> fromDb)
 {
     return fromDb.Any(item => submitter.Name == item.Name);
 }
 private static bool IsInSubmitterCollection(Submitter submitter, IEnumerable<Submitter> fromDb)
 {
     return fromDb.Any(item => submitter.UserId == item.UserId);
 }
        public void CanCheckAndAddSubmitterWhereNotExisting()
        {
            var submitter = new Submitter
            {
                Name = "TestSubmitter 7",
            };
            ISubmitterRepository repository = new SubmitterRepository();
            var fromDb = repository.List();
            Assert.IsFalse(IsInSubmitterNameCollection(submitter, fromDb));

            var newSubFromDb = repository.GetByUserId(repository.CheckExistingNamesAdd(submitter.Name));
            Assert.IsTrue(submitter.Name == newSubFromDb.Name);
        }
        public void CanAddNewSubmitter()
        {
            var submitter = new Submitter
            {
                Name = "TestSubmitter6",
            };

            ISubmitterRepository repository = new SubmitterRepository();
            repository.Add(submitter);

            // use session to try to load the Submitter
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Submitter>(submitter.UserId);
                // Test that the Submitter was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(submitter, fromDb);
                Assert.AreEqual(submitter.Name, fromDb.Name);
            }
        }