public Domain.Myfashion.Domain.NewsLetter getAllNewsLetterDetailsbyId(Guid nlid)
        {
            //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 news details by id.
                        NHibernate.IQuery query = session.CreateQuery("from NewsLetter where Id=:adsid");

                        query.SetParameter("adsid", nlid);
                        Domain.Myfashion.Domain.NewsLetter grou = (Domain.Myfashion.Domain.NewsLetter)query.UniqueResult();
                        return(grou);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
Ejemplo n.º 2
0
 public string AddNewsLatter(string ObjNewsLatter)
 {
     try
     {
         Domain.Myfashion.Domain.NewsLetter objnewsLatter = (Domain.Myfashion.Domain.NewsLetter)(new JavaScriptSerializer().Deserialize(ObjNewsLatter, typeof(Domain.Myfashion.Domain.NewsLetter)));
         ObjNewsLetterRepository.AddNewsLetter(objnewsLatter);
         return(new JavaScriptSerializer().Serialize("Success"));
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error : " + ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Something went wrong!"));
     }
 }
 /// <AddNewsLetter>
 /// Add News Letter
 /// </AddNewsLetter>
 /// <param name="nl">Set Values in a NewsLetter Class Property and Pass the Object of NewsLetter Class.(Domein.NewsLetter)</param>
 public void AddNewsLetter(Domain.Myfashion.Domain.NewsLetter nl)
 {
     //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(nl);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
        /// <UpdateNewsLetter>
        /// Update News Letter
        /// </summary>
        /// <param name="nl">Set Values in a NewsLetter Class Property and Pass the Object of NewsLetter Class.(Domein.NewsLetter)</param>
        public void UpdateNewsLetter(Domain.Myfashion.Domain.NewsLetter nl)
        {
            //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 existing news.
                        //  session.CreateQuery("Update NewsLetter set SendStatus =1 where UserId = :UserId,SendDate = :SendDate and Id= :adsid")
                        //  int i = session.CreateQuery("Update NewsLetter set SendStatus ='1' where Id = :id")
                        //      .SetParameter("id",nl.Id)
                        //     // .SetParameter("uid", nl.UserId)
                        //      //.SetParameter("SendDate", nl.SendDate)
                        //      //.SetParameter("nid", nl.Id)
                        //      .ExecuteUpdate();
                        //transaction.Commit();

                        //  List<NewsLetter> alst = session.CreateQuery("from NewsLetter where Id ="+nl.Id+ " ")
                        ////.SetParameter("id", nl.Id)
                        //.List<NewsLetter>()
                        //.ToList<NewsLetter>();



                        int i = session.CreateQuery("Update NewsLetter set SendStatus ='1' where Id = :id")
                                .SetParameter("id", nl.UserId)
                                .ExecuteUpdate();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        // return 0;
                    }
                } //End Transaction
            }     //End Session
        }
 /// <getNewsLetterDetails>
 /// Get news letter details by news boy
 /// </summary>
 /// <param name="nlDetail">Message(Body) of new latter</param>
 /// <returns></returns>
 public Domain.Myfashion.Domain.NewsLetter getNewsLetterDetails(string nlDetail)
 {
     //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 news detail by new body.
                 NHibernate.IQuery query = session.CreateQuery("from NewsLetter where NewsLetterBody=:nlDetail");
                 query.SetParameter("nlDetail", nlDetail);
                 Domain.Myfashion.Domain.NewsLetter grou = query.UniqueResult <Domain.Myfashion.Domain.NewsLetter>();
                 return(grou);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }