Пример #1
0
        public int UpdateNote(Guid id)
        {
            NotesArchiveNHibernate Note = GetNote(id);
            int status = 1;

            if (Note == null)
            {
                return(0);
            }

            //Note.Name = name;
            //Note.Description = description;

            var nHibernateSession = new NHibernateFactory().GetSessionFactory().OpenSession();

            try
            {
                using (var transaction = nHibernateSession.BeginTransaction())
                {
                    nHibernateSession.SaveOrUpdate(Note);
                    transaction.Commit();
                }
            }
            catch (Exception e)
            {
                ExceptionManager.Publish(e);
                status = 0;
            }
            finally
            {
                nHibernateSession.Close();
            }

            return(status);
        }
Пример #2
0
        public void DeleteNote(Guid NOTE_ID)
        {
            NotesArchiveNHibernate Note = GetNote(NOTE_ID);

            if (Note == null)
            {
                return;
            }
            var nHibernateSession = new NHibernateFactory().GetSessionFactory().OpenSession();

            try
            {
                using (var transaction = nHibernateSession.BeginTransaction())
                {
                    nHibernateSession.Delete(Note);
                    transaction.Commit();
                }
            }
            catch (Exception e)
            {
                ExceptionManager.Publish(e);
            }
            finally
            {
                nHibernateSession.Close();
            }
        }
Пример #3
0
        public NotesArchiveNHibernate GetNote(Guid NOTE_ID)
        {
            var nHibernateSession       = new NHibernateFactory().GetSessionFactory().OpenSession();
            NotesArchiveNHibernate Note = new NotesArchiveNHibernate();

            try
            {
                Note = nHibernateSession.Query <NotesArchiveNHibernate>().FirstOrDefault(x => x.NOTE_ID == NOTE_ID);
            }
            catch (Exception e)
            {
                ExceptionManager.Publish(e);
            }
            finally
            {
                nHibernateSession.Close();
            }
            return(Note);
        }