public int UpdateNote(Guid id, string subject, string note) { NotesNHibernate 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); }
public void DeleteNote(Guid NOTE_ID) { NotesNHibernate 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(); } }
public NotesNHibernate GetNote(Guid NOTE_ID) { var nHibernateSession = new NHibernateFactory().GetSessionFactory().OpenSession(); NotesNHibernate Note = new NotesNHibernate(); try { Note = nHibernateSession.Query <NotesNHibernate>().FirstOrDefault(x => x.NOTE_ID == NOTE_ID); } catch (Exception e) { ExceptionManager.Publish(e); } finally { nHibernateSession.Close(); } return(Note); }