Ejemplo n.º 1
0
 /// <UpdateAds>
 /// update/change a ImageUrl,Script,ExpiryDate and Status of existing Ads.
 /// </summary>
 /// <param name="ads">Set Values in a Ads Class Property and Pass the Object of Ads Class.(Domain.Ads)</param>
 public void UpdateAds(Domain.Socioboard.Domain.Ads ads)
 {
     //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 Delete Data.
                 // And Set the reuired paremeters to find the specific values.
                 session.CreateQuery("Update Ads set ImageUrl =:imageurl,Script=:script,ExpiryDate=:expirydate,Status=:status where Id = :adsid")
                 .SetParameter("script", ads.Script)
                 .SetParameter("imageurl", ads.ImageUrl)
                 .SetParameter("status", ads.Status)
                 .SetParameter("adsid", ads.Id)
                 .SetParameter("expirydate", ads.ExpiryDate)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End using transaction.
     }     //End using session.
 }
Ejemplo n.º 2
0
 /// <getAdsDetailsbyId>
 /// get ads details by Ads Guid.
 /// </summary>
 /// <param name="adsid">Id of the Ads(Guid)</param>
 /// <returns>Return Unique object of Ads</returns>
 public Domain.Socioboard.Domain.Ads getAdsDetailsbyId(Guid adsid)
 {
     //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 the action to get data by query.
                 // Where we set the parameter
                 // And return unique result of Ad
                 NHibernate.IQuery query = session.CreateQuery("from Ads where Id=:adsid");
                 query.SetParameter("adsid", adsid);
                 Domain.Socioboard.Domain.Ads grou = query.UniqueResult <Domain.Socioboard.Domain.Ads>();
                 return(grou);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } // End using transaction
     }     // End using session
 }
Ejemplo n.º 3
0
 /// <AddAds>
 /// Add a new Advertisement in a Database.
 /// </summary>
 /// <param name="ads">Set Values in a Ads Class Property and Pass the Object of Ads Class.(Domain.Ads)</param>
 public void AddAds(Domain.Socioboard.Domain.Ads ads)
 {
     //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())
         {
             //Process action to save data.
             session.Save(ads);
             transaction.Commit();
         } //End using transaction.
     }     //End using session.
 }
Ejemplo n.º 4
0
 public Domain.Socioboard.Domain.Ads getAdsDetails(string adsUrl)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 NHibernate.IQuery query = session.CreateQuery("from Package where ImageUrl=:adsUrl");
                 query.SetParameter("adsUrl", adsUrl);
                 Domain.Socioboard.Domain.Ads grou = query.UniqueResult <Domain.Socioboard.Domain.Ads>();
                 return(grou);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         }
     }
 }