public void addFacebookStats(FacebookStats fbstats)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(fbstats);
                    transaction.Commit();

                }
            }
        }
 public void updateFacebookStats(FacebookStats fbaccount)
 {
     throw new NotImplementedException();
 }
        private void AddFacebookStats(string UserId, FacebookClient fb, dynamic profile)
        {
            try
            {
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                dynamic friendsgenderstats = fb.Get("v2.0/" + profile["id"] + "/friends?fields=gender");
                Domain.Myfashion.Domain.FacebookStats objfbStats = new Domain.Myfashion.Domain.FacebookStats();
                FacebookStatsRepository objFBStatsRepo = new FacebookStatsRepository();
                int malecount = 0;
                int femalecount = 0;
                foreach (var item in friendsgenderstats["data"])
                {
                    if (item["gender"] == "male")
                        malecount++;
                    else if (item["gender"] == "female")
                        femalecount++;
                }
                objfbStats.EntryDate = DateTime.Now;
                objfbStats.FbUserId = profile["id"].ToString();
                objfbStats.FemaleCount = femalecount;
                objfbStats.Id = Guid.NewGuid();
                objfbStats.MaleCount = malecount;
                objfbStats.UserId = Guid.Parse(UserId);


                #region fancount
                int fancountPage = 0;
                try
                {
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + objfbStats.FbUserId });
                    //foreach (var friend in fancount.data)
                    //{
                    //    fancountPage = Convert.ToInt32(friend.fan_count);
                    //}

                    dynamic friends = fb.Get("v2.0/" + objfbStats.FbUserId + "/friends");
                    fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString());

                }
                catch (Exception)
                {
                    fancountPage = 0;
                }
                #endregion

                objfbStats.FanCount = fancountPage;//getfanCount(objfbStats,fb.AccessToken.ToString());
                objFBStatsRepo.addFacebookStats(objfbStats);

            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }

        }