예제 #1
0
 public Domain.Myfashion.Domain.Invitation GetInvitationInfoBycode(string code)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 NHibernate.IQuery query = session.CreateQuery("from Invitation where InvitationCode=:code")
                                           .SetParameter("code", code);
                 Domain.Myfashion.Domain.Invitation _Invitation = (Domain.Myfashion.Domain.Invitation)query.UniqueResult();
                 return(_Invitation);
             }
             catch (Exception ex)
             {
                 return(null);
             }
         }
     }
 }
예제 #2
0
 /// <Add>
 /// Add a new invitation in DataBase.
 public void Add(Domain.Myfashion.Domain.Invitation invitation)
 {
     try
     {
         //Creates a database connection and opens up a session
         using (NHibernate.ISession session = SessionFactory.GetNewSession())
         {
             //After Session creation, start Transaction.
             using (NHibernate.ITransaction transaction = session.BeginTransaction())
             {
                 //Proceed action to save data.
                 session.Save(invitation);
                 transaction.Commit();
             } //End Using trasaction
         }     //End Using session
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
 }