/// <addGoogleAnalyticsUser>
 /// Add New Google Analytics User
 /// </summary>
 /// <param name="gaaccount">Set Values in a GoogleAnalyticsAccount Class Property and Pass the same Object of GoogleAnalyticsAccount Class.(Domain.GoogleAnalyticsAccount)</param>
 public void addGoogleAnalyticsUser(GoogleAnalyticsAccount gaaccount)
 {
     //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(gaaccount);
             transaction.Commit();
         }//End Transaction
     }//End Session
 }
        /// <updateGoogelAnalyticsUser>
        /// update Googel Analytics User Details
        /// </summary>
        /// <param name="gaaccount">Set Values in a GoogleAnalyticsAccount Class Property and Pass the same Object of GoogleAnalyticsAccount Class.(Domain.GoogleAnalyticsAccount)</param>
        public void updateGoogelAnalyticsUser(GoogleAnalyticsAccount gaaccount)
        {
            //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 google account deatils.
                        session.CreateQuery("Update GoogleAnalyticsAccount set GaAccountName =:gausername,GaProfileId=:gaprofileid,GaProfileName=:gaprofilename,AccessToken =:access,RefreshToken=:refreshtoken,EmailId=:emailid,IsActive=:status where GaAccountId = :gauserid and UserId = :userid")
                            .SetParameter("gausername", gaaccount.GaAccountName)
                            .SetParameter("gaprofilename",gaaccount.GaProfileName)
                            .SetParameter("gaprofileid",gaaccount.GaProfileId)
                            .SetParameter("access", gaaccount.AccessToken)
                            .SetParameter("refreshtoken",gaaccount.RefreshToken)
                            //.SetParameter("visits", gaaccount.Visits)
                            //.SetParameter("newvisits", gaaccount.NewVisits)
                            //.SetParameter("avgvisits", gaaccount.AvgVisits)
                            .SetParameter("emailid", gaaccount.EmailId)
                            .SetParameter("gauserid", gaaccount.GaAccountId)
                            .SetParameter("userid", gaaccount.UserId)
                            .SetParameter("status", gaaccount.IsActive)
                            .ExecuteUpdate();
                        transaction.Commit();


                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        // return 0;
                    }
                }//End Transaction
            }//End Session
        }
 /// <getGoogelAnalyticsAccountHomeDetailsById>
 /// Get the Googel Analytics Account Home Details By Id and google account id.
 /// </summary>
 /// <param name="gauserid">Google account id (String)</param>
 /// <param name="userId">Id of user(Guid)</param>
 /// <returns>Return object of Google analytic class.(Domein.GoogleAnalyticsAccount)</returns>
 public GoogleAnalyticsAccount getGoogelAnalyticsAccountHomeDetailsById(Guid userId, string gauserid)
 {
     //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
             {
                 NHibernate.IQuery query = session.CreateQuery("from GoogleAnalyticsAccount where GaAccountId = :GaAccountId and UserId=:userId");
                 query.SetParameter("GaAccountId", gauserid);
                 query.SetParameter("userId", userId);
                 GoogleAnalyticsAccount result = new GoogleAnalyticsAccount();
                 foreach (GoogleAnalyticsAccount item in query.Enumerable<GoogleAnalyticsAccount>())
                 {
                     result = item;
                     break;
                 }
                 return result;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return null;
             }
         }//End Transaction
     }//End session
 }