/// <DeleteArchiveMessage>
 /// Delete a ArchieveMessage From Database by UserId and Message.
 /// </summary>
 /// <param name="archive">the object of the ArchieveMessage class(Domain.ArchieveMEssage)</param>
 /// <returns>Return 1 for True and 0 for False</returns>
 public int DeleteArchiveMessage(Domain.Myfashion.Domain.ArchiveMessage archive)
 {
     //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())
         {
             try
             {
                 // Proceed action to Detele specific data.
                 // return the integer value when it is success or not (0 or 1).
                 NHibernate.IQuery query = session.CreateQuery("delete from ArchiveMessage where UserId = :userid and Message = :message")
                                           .SetParameter("message", archive.Message)
                                           .SetParameter("userid", archive.UserId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return(isUpdated);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         } // End using trasaction
     }     // End using session
 }
 /// <getArchiveMessagebyId>
 /// Get ArchieveMessage by UserId and ArchieveId.
 /// </summary>
 /// <param name="userid">UserId of the ArchieveMessage(Guid)</param>
 /// <param name="archiveId">ArchieveId of the ArchieveMessage(Guid)</param>
 /// <returns>Return Unique object of Ads</returns>
 public Domain.Myfashion.Domain.ArchiveMessage getArchiveMessagebyId(Guid userid, Guid archiveid)
 {
     //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())
         {
             try
             {
                 //Proceed action, to get archive mesaages by user id and archive id.
                 NHibernate.IQuery query = session.CreateQuery("from ArchiveMessage where UserId = :userid and Id=:archivename");
                 query.SetParameter("userid", userid);
                 query.SetParameter("archivename", archiveid);
                 Domain.Myfashion.Domain.ArchiveMessage grou = query.UniqueResult <Domain.Myfashion.Domain.ArchiveMessage>();
                 return(grou);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } // End using transaction
     }     //End Using session
 }
 /// <UpdateArchiveMessage>
 /// update ArchieveMessage by UserId.
 /// </summary>
 /// <param name="archive">the object of the ArchieveMessage class(Domain.ArchieveMEssage).</param>
 public void UpdateArchiveMessage(Domain.Myfashion.Domain.ArchiveMessage archive)
 {
     //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())
         {
             try
             {
                 //Proceed action, to update Message by Id
                 session.CreateQuery("Update ArchiveMessage set Message =:message where UserId = :userid")
                 .SetParameter("message", archive.Message)
                 .SetParameter("userid", archive.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End using transaction
     }     // End using session
 }
 /// <AddArchiveMessage>
 /// Add a new  ArchieveMEssage in a database.
 /// </summary>
 /// <param name="archive">et Values in a ArchieveMEssage Class Property and Pass the Object of ArchieveMEssage Class.(Domain.ArchieveMEssage)</param>
 public void AddArchiveMessage(Domain.Myfashion.Domain.ArchiveMessage archive)
 {
     //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(archive);
             transaction.Commit();
         } // End Using Trasaction
     }     // End using session
 }